本文整理汇总了Java中javax.swing.JCheckBoxMenuItem.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Java JCheckBoxMenuItem.addItemListener方法的具体用法?Java JCheckBoxMenuItem.addItemListener怎么用?Java JCheckBoxMenuItem.addItemListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JCheckBoxMenuItem
的用法示例。
在下文中一共展示了JCheckBoxMenuItem.addItemListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPopupMenuItem
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
public JMenuItem getPopupMenuItem(JTextComponent target) {
item = new JCheckBoxMenuItem(NbBundle.getBundle(BaseKit.class).
getString("line-numbers-menuitem"), isLineNumbersVisible());
item.addItemListener( new ItemListener() {
public void itemStateChanged(ItemEvent e) {
actionPerformed(null,null);
}
});
return item;
}
示例2: getPopupMenuItem
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
JCheckBoxMenuItem item = new JCheckBoxMenuItem(
NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
toolbarVisible);
item.addItemListener( new ItemListener() {
public @Override void itemStateChanged(ItemEvent e) {
actionPerformed(null,null);
}
});
return item;
}
示例3: createTypeMenu
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
/**
* @return menu that allows to select possible column types
*/
private JMenu createTypeMenu() {
ButtonGroup typeGroup = new ButtonGroup();
JMenu typeChangeItem = new JMenu(CHANGE_TYPE_LABEL);
typeChangeItem.setToolTipText(CHANGE_TYPE_TIP);
for (final ColumnType columnType : ColumnType.values()) {
final JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(
DataImportWizardUtils.getNameForColumnType(columnType));
if (columnType == metaData.getColumnMetaData(columnIndex).getType()) {
checkboxItem.setSelected(true);
}
checkboxItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
changeType(columnType);
}
}
});
typeGroup.add(checkboxItem);
typeChangeItem.add(checkboxItem);
}
return typeChangeItem;
}
示例4: addCheckbox
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
/**
* Adds a checkbox item with a given name to the options, and returns the
* associated (fresh) menu item.
* @param name the name of the checkbox menu item to add
* @return the added {@link javax.swing.JCheckBoxMenuItem}
*/
private final JCheckBoxMenuItem addCheckbox(final String name) {
JCheckBoxMenuItem result = new JCheckBoxMenuItem(name);
boolean selected = userPrefs.getBoolean(name, boolOptionDefaults.get(name));
boolean enabled = isEnabled(name);
result.setSelected(selected & enabled);
this.itemMap.put(name, result);
if (enabled) {
result.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
userPrefs.putBoolean(name, e.getStateChange() == ItemEvent.SELECTED);
}
});
} else {
result.setEnabled(false);
}
return result;
}
示例5: initialize
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
private void initialize() {
mouseToolbarCheckbox = new JCheckBoxMenuItem("Mouse toolbar");
zoomToolbarCheckbox = new JCheckBoxMenuItem("Zoom toolbar");
simulationToolbarCheckbox = new JCheckBoxMenuItem("Simulation toolbar");
dbToolbarCheckbox = new JCheckBoxMenuItem("Explore toolbar");
undoToolbarCheckbox = new JCheckBoxMenuItem("Undo/Redo toolbar");
undoToolbarCheckbox.setSelected(true);
mouseToolbarCheckbox.addItemListener(this);
zoomToolbarCheckbox.addItemListener(this);
simulationToolbarCheckbox.addItemListener(this);
dbToolbarCheckbox.addItemListener(this);
undoToolbarCheckbox.addItemListener(this);
this.add(mouseToolbarCheckbox);
this.add(zoomToolbarCheckbox);
this.add(simulationToolbarCheckbox);
this.add(dbToolbarCheckbox);
this.add(undoToolbarCheckbox);
}
示例6: initialize
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
private void initialize() {
mouseToolbarCheckbox = new JCheckBoxMenuItem("Mouse toolbar");
zoomToolbarCheckbox = new JCheckBoxMenuItem("Zoom toolbar");
simulationToolbarCheckbox = new JCheckBoxMenuItem("Simulation toolbar");
dbToolbarCheckbox = new JCheckBoxMenuItem("Explore toolbar");
undoToolbarCheckbox = new JCheckBoxMenuItem("Undo/Redo toolbar");
undoToolbarCheckbox.setSelected(true);
mouseToolbarCheckbox.addItemListener(this);
zoomToolbarCheckbox.addItemListener(this);
simulationToolbarCheckbox.addItemListener(this);
dbToolbarCheckbox.addItemListener(this);
undoToolbarCheckbox.addItemListener(this);
this.add(mouseToolbarCheckbox);
this.add(zoomToolbarCheckbox);
this.add(simulationToolbarCheckbox);
this.add(dbToolbarCheckbox);
this.add(undoToolbarCheckbox);
}
示例7: createPeer
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
@Override
public JCheckBoxMenuItem createPeer() {
final JCheckBoxMenuItem item = new JCheckBoxMenuItem(action);
item.setSelected(state);
item.addItemListener(this);
peers.add(new WeakReference<JCheckBoxMenuItem>(item, queue));
return item;
}
示例8: addAnswer
import javax.swing.JCheckBoxMenuItem; //导入方法依赖的package包/类
private void addAnswer(String answer) {
JCheckBoxMenuItem item = new JCheckBoxMenuItem(answer);
this.answerGroup.add(item);
this.add(item);
item.addItemListener(this);
}