本文整理汇总了Java中javax.swing.JCheckBoxMenuItem类的典型用法代码示例。如果您正苦于以下问题:Java JCheckBoxMenuItem类的具体用法?Java JCheckBoxMenuItem怎么用?Java JCheckBoxMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JCheckBoxMenuItem类属于javax.swing包,在下文中一共展示了JCheckBoxMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: init
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
@Override
public void init() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("Menu");
JCheckBoxMenuItem checkBoxMenuItem
= new JCheckBoxMenuItem("JCheckBoxMenuItem");
checkBoxMenuItem.setSelected(true);
menu.add(checkBoxMenuItem);
bar.add(menu);
setJMenuBar(bar);
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: setShowEditorToolbar
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
private static boolean setShowEditorToolbar( boolean show ) {
boolean res = true;
Action toggleEditorToolbar = FileUtil.getConfigObject( "Editors/Actions/toggle-toolbar.instance", Action.class ); //NOI18N
if( null != toggleEditorToolbar ) {
if( toggleEditorToolbar instanceof Presenter.Menu ) {
JMenuItem menuItem = ((Presenter.Menu)toggleEditorToolbar).getMenuPresenter();
if( menuItem instanceof JCheckBoxMenuItem ) {
JCheckBoxMenuItem checkBoxMenu = ( JCheckBoxMenuItem ) menuItem;
res = checkBoxMenu.isSelected();
if( checkBoxMenu.isSelected() != show ) {
try {
toggleEditorToolbar.actionPerformed( new ActionEvent( menuItem, 0, "")); //NOII18N
} catch( Exception ex ) {
//don't worry too much if it isn't working, we're just trying to be helpful here
Logger.getLogger( EditorOnlyDisplayer.class.getName()).log( Level.FINE, null, ex );
}
}
}
}
}
return res;
}
示例4: maybeShowPopup
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
protected void maybeShowPopup (MouseEvent evt) {
if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
return;
}
JPopupMenu pm = new JPopupMenu();
final Set<ProviderModel.Category> evalCats =
new LinkedHashSet<ProviderModel.Category>();
evalCats.addAll(CommandEvaluator.getEvalCats());
JMenuItem allCats = new AllMenuItem(evalCats);
pm.add(allCats);
for (ProviderModel.Category cat : ProviderModel.getInstance().getCategories()) {
if (!CommandEvaluator.RECENT.equals(cat.getName())) {
JCheckBoxMenuItem item = new CategoryCheckBoxMenuItem(cat,
evalCats);
pm.add(item);
}
}
pm.show(getInnerComponent(), 0, getInnerComponent().getHeight() - 1);
}
示例5: actionPerformed
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
public void actionPerformed(ActionEvent ev) {
Object source = ev.getSource();
// react just on submenu items, not on submenu click itself
if (source instanceof JCheckBoxMenuItem) {
JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem)source;
String filterName = (String)(menuItem.getClientProperty(PROP_FILTER_NAME));
filtersDesc.setSelected(filterName, menuItem.isSelected());
}
}
示例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: 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;
}
示例8: 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;
}
示例9: initMenu
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
void initMenu() {
addLoc = new JMenuItem("Add Place");
menu.add( addLoc );
addLoc.addActionListener( this );
loadLoc = new JMenuItem("Load Places");
menu.add( loadLoc );
loadLoc.addActionListener( this );
editLoc = new JMenuItem("Edit Places");
menu.add( editLoc );
editLoc.addActionListener( this );
editLoc.setEnabled(false);
showLoc = new JCheckBoxMenuItem("Show Places", false);
menu.add( showLoc );
showLoc.addActionListener( this );
// showLoc.setEnabled(false);
menu.addSeparator();
list = new JCheckBox("add to list", true);
save = new JCheckBox("save to file", false);
newSave = new JCheckBox("save to new file", false);
addPresetLocations();
// addMyLocations();
}
示例10: getJCheckBoxMenuItem
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
/**
* Return the jcheckboxmenuitem to get added for a menubar
* @param c Component Location
* @return JCheckBoxMenuItem
*/
public JCheckBoxMenuItem getJCheckBoxMenuItem(Component c) {
JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem("Show Console");
cbmi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(cbmi.isSelected()) {
reShowConsole(c);
} else {
hideConsole();
}
}
});
menucheckboxitems.add(cbmi);
return cbmi;
}
示例11: 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;
}
示例12: paintMenuItem
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
/**
* Paints a menu item
* @param g The graphics to use
* @param menuItem The menu item to paint
* @param hasCursor Whether or not the cursor is over the component
* @param defaultTextIconGap The gap between the text and the icon
*/
private static final void paintMenuItem(Graphics2D g, JMenuItem menuItem, boolean hasCursor, int defaultTextIconGap){
g.setColor(Main.config.customColors ? Main.config.background : Color.BLACK);
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
if(menuItem instanceof JCheckBoxMenuItem && menuItem.isSelected()){
g.drawImage(ColorManager.checkmark, 0, 0, 22, 22, 0, 0, 100, 100, menuItem);
}else if(menuItem instanceof JMenu){
g.drawImage(ColorManager.arrow, menuItem.getWidth() - 12, 5, menuItem.getWidth(), 17, 0, 0, 128, 128, menuItem);
}
g.setColor(Main.config.customColors ? Main.config.foreground : Color.CYAN);
if(hasCursor){
g.drawLine(0, 0, menuItem.getWidth(), 0);
g.drawLine(0, menuItem.getHeight() - 1, menuItem.getWidth(), menuItem.getHeight() - 1);
Composite prev = g.getComposite();
g.setComposite(MenuItemUI.mode);
g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
g.setComposite(prev);
}
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
int y = (22 - fm.getHeight()) / 2;
SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, menuItem.getText(), mnemIndex, 22 + defaultTextIconGap, y + fm.getAscent());
}
示例13: MultiUDPNetworkDVS128Camera
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
public MultiUDPNetworkDVS128Camera() {
setName("MultiUDPNetworkDVS128Camera");
setSizeX(MAX_NUM_CAMERAS * 128);
setSizeY(128);
setEventExtractor(new Extractor(this));
chipMenu = new JMenu("MultiCamera");
chipMenu.getPopupMenu().setLightWeightPopupEnabled(false);
chipMenu.add(new JMenuItem(new ShowClientMapperAction()));
loadClientMappingPrefs();
displayMethod=new MultiUDPNetworkDVS128CameraDisplayMethod(getCanvas());
getCanvas().addDisplayMethod(displayMethod);
getCanvas().setDisplayMethod(displayMethod);
chipMenu.add(new JCheckBoxMenuItem(new DisplayCameraInfoAction(displayMethod)));
chipMenu.add(new JMenuItem(new ShowPowerSettingsAction()));
activateCameras();
}
示例14: buildViewMenu
import javax.swing.JCheckBoxMenuItem; //导入依赖的package包/类
private void buildViewMenu() {
ButtonGroup buttonGroup = new ButtonGroup();
setCodeHMenu(new JMenu("Code highlighting"));
raCodeHighLighting = new JCheckBoxMenuItem("Relational Algebra", true);
sqlCodeHighLighting = new JCheckBoxMenuItem("SQL", true);
getCodeHMenu().add(raCodeHighLighting);
getCodeHMenu().add(sqlCodeHighLighting);
setShowMenu(new JMenu("Show"));
consoleShow = new JCheckBoxMenuItem("Console", true);
dbViewerShow = new JCheckBoxMenuItem("DB Viewer", true);
queriesListShow = new JCheckBoxMenuItem("Query List", true);
getShowMenu().add(dbViewerShow);
getShowMenu().add(queriesListShow);
getShowMenu().add(consoleShow);
setViewMenu(new JMenu());
getViewMenu().setMnemonic(KeyEvent.VK_V);
getViewMenu().add(getCodeHMenu());
getViewMenu().add(getShowMenu());
}
示例15: 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);
}