本文整理匯總了Java中javax.swing.JToggleButton.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java JToggleButton.setEnabled方法的具體用法?Java JToggleButton.setEnabled怎麽用?Java JToggleButton.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.setEnabled方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createToggle
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private JToggleButton createToggle(Map<String, Boolean> fStates, int index) {
boolean isSelected = filtersDesc.isSelected(index);
boolean enabled = filtersDesc.isEnabled(index);
Icon icon = filtersDesc.getIcon(index);
// ensure small size, just for the icon
JToggleButton result = new JToggleButton(icon, enabled && isSelected);
Dimension size = new Dimension(21, 21); // 3 less than other buttons
result.setMaximumSize(size);
result.setMinimumSize(size);
result.setPreferredSize(size);
if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N
result.setBorderPainted(true);
} else {
result.setBorderPainted(false);
}
// result.setMargin(new Insets(2, 3, 2, 3));
result.setToolTipText(filtersDesc.getTooltip(index));
result.setEnabled(enabled);
fStates.put(filtersDesc.getKey(index), Boolean.valueOf(isSelected));
return result;
}
示例2: setEnabled
import javax.swing.JToggleButton; //導入方法依賴的package包/類
/**
* In addition to delegating the method to the label list and to
* <tt>super</tt>, sets the background color to <tt>null</tt> when disabled
* and back to the default when enabled.
*/
@Override
public void setEnabled(boolean enabled) {
if (enabled != isEnabled()) {
if (!enabled) {
this.enabledBackground = getBackground();
setBackground(null);
} else if (this.enabledBackground != null) {
setBackground(this.enabledBackground);
}
if (getLabelTree() != null) {
getLabelTree().setEnabled(enabled);
}
for (JToggleButton button : getModeButtonMap().values()) {
button.setEnabled(enabled);
}
getModeButton(getDefaultMode()).setSelected(true);
// retrieve the layout action to get its key accelerator working
getLayoutAction();
super.setEnabled(enabled);
}
}
示例3: getModeButtonMap
import javax.swing.JToggleButton; //導入方法依賴的package包/類
private Map<JGraphMode,JToggleButton> getModeButtonMap() {
if (this.modeButtonMap == null) {
this.modeButtonMap = new EnumMap<>(JGraphMode.class);
ButtonGroup modeButtonGroup = new ButtonGroup();
for (JGraphMode any : JGraphMode.values()) {
JToggleButton button = new JToggleButton(getModeAction(any));
Options.setLAF(button);
button.setToolTipText(any.getName());
button.setEnabled(isEnabled());
this.modeButtonMap.put(any, button);
modeButtonGroup.add(button);
}
this.modeButtonMap.get(EDIT_MODE).setSelected(true);
}
return this.modeButtonMap;
}