Java Code Examples for javax.swing.JComponent#setEnabled()

The following examples show how to use javax.swing.JComponent#setEnabled() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Set the current leader of the group.
 *
 * @param name leader name
 */
void setLeader(String name) {
	memberList.setLeader(name);

	if (name.equals(User.getCharacterName())) {
		inviteButton.setEnabled(true);
		inviteButton.setToolTipText(INVITE_TOOLTIP);
	}
	// The same invite will not work more than once
	expireInvite(name);
	// The others are still valid, but can not be used while a member of a
	// group
	for (JComponent button : invites.values()) {
		button.setEnabled(false);
	}
	/*
	 * If the user was already in a group at login time, she may get a group
	 * message before switching to the group tab. Suppress the initial
	 * status request in that case.
	 */
	initialized = true;
}
 
Example 2
@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
  if ((getParameters() == null) || (getParameters().length == 0))
    return ExitCode.OK;
  ParameterSetupDialog dialog = new ParameterSetupDialog(parent, valueCheckRequired, this);

  int level = getParameter(msLevel).getValue() == null ? 2 : getParameter(msLevel).getValue();

  IntegerComponent msLevelComp = (IntegerComponent) dialog.getComponentForParameter(msLevel);
  JComponent mzTolPrecursor = dialog.getComponentForParameter(mzTolerancePrecursor);
  mzTolPrecursor.setEnabled(level > 1);
  msLevelComp.addDocumentListener(new DelayedDocumentListener(e -> {
    try {
      int level2 = Integer.parseInt(msLevelComp.getText());
      mzTolPrecursor.setEnabled(level2 > 1);
    } catch (Exception ex) {
      // do nothing user might be still typing
      mzTolPrecursor.setEnabled(false);
    }
  }));

  dialog.setVisible(true);
  return dialog.getExitCode();
}
 
Example 3
Source Project: netbeans   File: AddDOMBreakpointAction.java    License: Apache License 2.0 6 votes vote down vote up
private PopupPresenter(Node[] activatedNodes, boolean enabled) {
    items = new JCheckBoxMenuItem[] {
        new JCheckBoxMenuItem(Bundle.CTL_BreakOnSubtreeModif()),
        new JCheckBoxMenuItem(Bundle.CTL_BreakOnAttributesModif()),
        new JCheckBoxMenuItem(Bundle.CTL_BreakOnNodeRemove()),
    };
    if (!enabled) {
        for (JComponent c : items) {
            c.setEnabled(false);
        }
    } else {
        DOMBreakpoint[] domBreakpoints = findDOMBreakpoints();
        for (int i = 0; i < activatedNodes.length; i++) {
            Node node = activatedNodes[i];
            final org.netbeans.modules.web.webkit.debugging.api.dom.Node domNode;
            domNode = node.getLookup().lookup(org.netbeans.modules.web.webkit.debugging.api.dom.Node.class);
            DOMBreakpoint db = findBreakpointOn(domNode, node, domBreakpoints);
            bind(items[0], node, DOMBreakpoint.Type.SUBTREE_MODIFIED, db, domNode);
            bind(items[1], node, DOMBreakpoint.Type.ATTRIBUTE_MODIFIED, db, domNode);
            bind(items[2], node, DOMBreakpoint.Type.NODE_REMOVED, db, domNode);
        }
    }
}
 
Example 4
/**
 * Set the member list.
 *
 * @param members list of members
 */
void setMembers(List<String> members) {
	memberList.setMembers(members);
	boolean isInAGroup = members != null;
	memberLabel.setVisible(isInAGroup);
	leaveGroupButton.setEnabled(isInAGroup);
	messageButton.setEnabled(isInAGroup);
	// Disable for now if the user is in a group, and enable it again
	// if she is the group leader
	inviteButton.setEnabled(!isInAGroup);
	if (!isInAGroup) {
		inviteButton.setToolTipText(START_GROUP_TOOLTIP);
	}
	// Enable any still valid invites at leaving a group
	if (!isInAGroup) {
		for (JComponent button : invites.values()) {
			button.setEnabled(true);
		}
	}
}
 
Example 5
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected,
    boolean expanded, boolean leaf, int row, boolean hasFocus) {

  JComponent c = (JComponent) super.getTreeCellRendererComponent(tree, value, isSelected,
      expanded, leaf, row, hasFocus);

  if (value instanceof DisableableTreeNode)
    c.setEnabled(((DisableableTreeNode) value).isEnabled());

  return c;
}
 
Example 6
@Override
public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);

    if (this.userAccountsComboBox != null) {
        this.userAccountsComboBox.setEnabled(enabled);
    }
    this.missionsComboBox.setEnabled(enabled);
    for (int i=0; i<this.parameterComponents.size(); i++) {
        JComponent component = this.parameterComponents.get(i).getComponent();
        component.setEnabled(enabled);
    }
}
 
Example 7
Source Project: netbeans   File: ClassNameList.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    TableCellRenderer def = table.getDefaultRenderer(table.getColumnClass(column));
    if (!table.isEnabled()) {
        isSelected = hasFocus = false;
    }
    JComponent c = (JComponent)def.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    c.setEnabled(table.isEnabled());
    
    return c;
}
 
Example 8
Source Project: netbeans   File: CustomizerJar.java    License: Apache License 2.0 5 votes vote down vote up
private void enableJLink() {
    final boolean correctSourceLevel = isJLinkEnabled();
    for (Map.Entry<JComponent,Collection<Supplier<Boolean>>> e : jLinkComponents.entrySet()) {
        final JComponent c = e.getKey();
        c.setEnabled(e.getValue().stream().map(Supplier::get).reduce(correctSourceLevel, (a,b) -> a&&b));
        if (c instanceof AbstractButton) {
            ButtonModelDecorator.cast(((AbstractButton)c).getModel())
                    .ifPresent((model) -> model.setOverride(correctSourceLevel ? null : false));
        }
    }
}
 
Example 9
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 10
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 11
Source Project: hottub   File: ImageTests.java    License: GNU General Public License v2.0 4 votes vote down vote up
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 12
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}
 
Example 13
Source Project: netbeans   File: CustomizerJar.java    License: Apache License 2.0 4 votes vote down vote up
private void enableJLink() {
    for (Map.Entry<JComponent,Collection<Supplier<Boolean>>> e : jLinkComponents.entrySet()) {
        final JComponent c = e.getKey();
        c.setEnabled(e.getValue().stream().map(Supplier::get).reduce(true, (a,b) -> a&&b));
    }
}
 
Example 14
Source Project: netbeans   File: SelectUriStep.java    License: Apache License 2.0 4 votes vote down vote up
private void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
    repository.setEnabled(enabled);
}
 
Example 15
Source Project: netbeans   File: PhpDebuggerPanel.java    License: Apache License 2.0 4 votes vote down vote up
void enableDependentFields(boolean selected) {
    for (JComponent component : dependentFields) {
        component.setEnabled(selected);
    }
}
 
Example 16
Source Project: netbeans   File: CustomizerPhpUnit.java    License: Apache License 2.0 4 votes vote down vote up
void enableFile(boolean enabled, JComponent... components) {
    for (JComponent component : components) {
        component.setEnabled(enabled);
    }
}
 
Example 17
private void removeLink(JComponent component) {
    this.sourceLink = null;
    component.setEnabled(false);
    component.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    component.setToolTipText("");
}
 
Example 18
Source Project: netbeans   File: CustomizerCodeception.java    License: Apache License 2.0 4 votes vote down vote up
void enableFile(boolean enabled, JComponent... components) {
    for (JComponent component : components) {
        component.setEnabled(enabled);
    }
}
 
Example 19
Source Project: netbeans   File: RemoteRepository.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
}
 
Example 20
Source Project: netbeans   File: GrailsCommandChooser.java    License: Apache License 2.0 4 votes vote down vote up
private void setEnabled(final JComponent[] comps, final boolean enabled) {
    for (JComponent comp : comps) {
        comp.setEnabled(enabled);
    }

}