/** * Sets the selected state of the button from the action. This is defined here, but not wired up. Subclasses like * JToggleButton and JCheckBoxMenuItem make use of it. * * @param a the Action */ private void setSelectedFromAction(Action a) { boolean selected = false; if (a != null) { selected = isSelected(a); } if (selected != isSelected()) { // This won't notify ActionListeners, but that should be // ok as the change is coming from the Action. setSelected(selected); // Make sure the change actually took effect if (!selected && isSelected()) { if (getModel() instanceof DefaultButtonModel) { ButtonGroup group = ((DefaultButtonModel) getModel()).getGroup(); if (group != null && SystemInfo.isJdk6Above()) { group.clearSelection(); } } } } }