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

The following examples show how to use javax.swing.JComponent#setEnabled() . 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
Source File: GroupPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: LocalSpectralDBSearchParameters.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
@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 File: AddDOMBreakpointAction.java    From netbeans with 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
Source File: GroupPanel.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: DisableableTreeCellRenderer.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@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
Source File: RemoteProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@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 File: ClassNameList.java    From netbeans with 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 File: CustomizerJar.java    From netbeans with 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
Source File: GrailsCommandChooser.java    From netbeans with 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);
    }

}
 
Example 10
Source File: RemoteRepository.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected void setEnabled (boolean enabled) {
    for (JComponent inputField : inputFields) {
        inputField.setEnabled(enabled);
    }
}
 
Example 11
Source File: CustomizerCodeception.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void enableFile(boolean enabled, JComponent... components) {
    for (JComponent component : components) {
        component.setEnabled(enabled);
    }
}
 
Example 12
Source File: MainFrameComponentFactory.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void removeLink(JComponent component) {
    this.sourceLink = null;
    component.setEnabled(false);
    component.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    component.setToolTipText("");
}
 
Example 13
Source File: CustomizerPhpUnit.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void enableFile(boolean enabled, JComponent... components) {
    for (JComponent component : components) {
        component.setEnabled(enabled);
    }
}
 
Example 14
Source File: PhpDebuggerPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void enableDependentFields(boolean selected) {
    for (JComponent component : dependentFields) {
        component.setEnabled(selected);
    }
}
 
Example 15
Source File: SelectUriStep.java    From netbeans with 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 16
Source File: CustomizerJar.java    From netbeans with 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 17
Source File: ImageTests.java    From jdk8u-jdk with 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 18
Source File: ImageTests.java    From hottub with 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 19
Source File: ImageTests.java    From openjdk-8-source with 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 20
Source File: ImageTests.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public JComponent getJComponent() {
    JComponent comp = super.getJComponent();
    comp.setEnabled(possible);
    return comp;
}