Java Code Examples for javax.swing.JCheckBoxMenuItem#addActionListener()
The following examples show how to use
javax.swing.JCheckBoxMenuItem#addActionListener() .
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: ContextualMenuHelper.java From PyramidShader with GNU General Public License v3.0 | 6 votes |
public void addToggle(final BooleanProperty property,final Runnable runnable) { final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(property.getName()); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { property.setValue(menuItem.isSelected()); SwingUtilities.invokeLater(runnable); } }); property.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { menuItem.setSelected(property.getValue()); } }); SwingUtilities.invokeLater(runnable); } }); popup.add(menuItem); }
Example 2
Source File: GuiUtils.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Creates a check box menu item which text is specified by a textKey, its value is bound to the specified settingKey.<br> * The text will be set by calling the {@link GuiUtils#updateButtonText(AbstractButton, String, Object...)}.<br> * The initial selection value of the check box menu item will be taken from the {@link Settings}, * and an action listener will be added to the menu item to register changes at the {@link Settings}. * * @param textKey key of the text of the check box menu item * @param settingKey key of the settings its value is bound to * @param icon optional icon of the menu item * @return the created check box menu item */ public static JCheckBoxMenuItem createCheckBoxMenuItem( final String textKey, final String settingKey, final Icon icon ) { final JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem(); GuiUtils.updateButtonText( checkBoxMenuItem, textKey ); if ( icon != null ) checkBoxMenuItem.setIcon( icon ); checkBoxMenuItem.setSelected( Settings.getBoolean( settingKey ) ); checkBoxMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed( final ActionEvent event ) { Settings.set( settingKey, checkBoxMenuItem.isSelected() ); } } ); return checkBoxMenuItem; }
Example 3
Source File: ContextualMenuHelper.java From pumpernickel with MIT License | 6 votes |
/** * * @param property * @param runnable * an optional runnable to invoke when the property changes. This * may be null. * @return */ public JMenuItem addToggle(final BooleanProperty property, final Runnable runnable) { final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem( property.getName(), property.getValue()); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { property.setValue(menuItem.isSelected()); if (runnable != null) SwingUtilities.invokeLater(runnable); } }); property.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { menuItem.setSelected(property.getValue()); } }); if (runnable != null) SwingUtilities.invokeLater(runnable); } }); popup.add(menuItem); return menuItem; }
Example 4
Source File: ViewMenu.java From triplea with GNU General Public License v3.0 | 5 votes |
private void addShowUnitsMenu() { final JCheckBoxMenuItem showUnitsBox = new JCheckBoxMenuItem("Show Units"); showUnitsBox.setMnemonic(KeyEvent.VK_U); showUnitsBox.setSelected(true); showUnitsBox.addActionListener( e -> { final boolean tfselected = showUnitsBox.isSelected(); uiContext.setShowUnits(tfselected); frame.getMapPanel().resetMap(); }); add(showUnitsBox); }
Example 5
Source File: EditorRootPane.java From libGDX-Path-Editor with Apache License 2.0 | 5 votes |
private JMenu createAddPathMenu(){ JMenu menu = new JMenu(MenuConsts.path); addVertex = new JCheckBoxMenuItem(MenuConsts.addVertex); addVertex.setIcon(new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_menu_addVertex))); addVertex.addActionListener(menuHandler); menu.add(addVertex); editVertex = new JCheckBoxMenuItem(MenuConsts.moveVertex); editVertex.setIcon(new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_menu_editVertex))); editVertex.addActionListener(menuHandler); menu.add(editVertex); insertVertex = new JCheckBoxMenuItem(MenuConsts.insertVertex); insertVertex.setIcon(new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_menu_insertVertex))); insertVertex.addActionListener(menuHandler); menu.add(insertVertex); removeVertex = new JCheckBoxMenuItem(MenuConsts.removeVertex); removeVertex.setIcon(new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_menu_removeVertex))); removeVertex.addActionListener(menuHandler); menu.add(removeVertex); menu.add(new JSeparator()); clearPath = new JMenuItem(MenuConsts.clearPath); clearPath.setIcon(new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_menu_clearPath))); clearPath.addActionListener(menuHandler); menu.add(clearPath); return menu; }
Example 6
Source File: SwingSet2.java From beautyeye with Apache License 2.0 | 5 votes |
/** * Create a checkbox menu menu item. * * @param menu the menu * @param label the label * @param mnemonic the mnemonic * @param accessibleDescription the accessible description * @param action the action * @return the j menu item */ private JMenuItem createCheckBoxMenuItem(JMenu menu, String label, String mnemonic, String accessibleDescription, Action action) { JCheckBoxMenuItem mi = (JCheckBoxMenuItem)menu.add( new JCheckBoxMenuItem(getString(label))); mi.setMnemonic(getMnemonic(mnemonic)); mi.getAccessibleContext().setAccessibleDescription(getString( accessibleDescription)); mi.addActionListener(action); return mi; }
Example 7
Source File: AccountImportDialog.java From jeveassets with GNU General Public License v2.0 | 5 votes |
private void updateScopes() { scopesMap.clear(); jScopes.removeAll(); if (jCharacter.isSelected()) { jType.setText(DialoguesAccount.get().character()); } else { jType.setText(DialoguesAccount.get().corporation()); } for (EsiScopes scope : EsiScopes.values()) { if (scope.isPublicScope()) { continue; } if (jCharacter.isSelected() && !scope.isCharacterScope()) { continue; } if (jCorporation.isSelected() && !scope.isCorporationScope()) { continue; } JCheckBoxMenuItem jCheckBoxMenuItem = new JCheckBoxMenuItem(scope.toString()); jCheckBoxMenuItem.setSelected(true); jCheckBoxMenuItem.setEnabled(!scope.isForced()); jCheckBoxMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean enabled = false; for (Map.Entry<EsiScopes, JCheckBoxMenuItem> entry : scopesMap.entrySet()) { if (entry.getValue().isSelected() && !entry.getKey().isForced()) { enabled = true; break; } } jBrowse.setEnabled(enabled); } }); jScopes.add(jCheckBoxMenuItem, true); scopesMap.put(scope, jCheckBoxMenuItem); } }
Example 8
Source File: RenderingHintsContextMenu.java From pumpernickel with MIT License | 5 votes |
public void addOption(Object value, String valueName, String valueUserName) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(valueUserName); item.addActionListener(actionListener); add(item); item.putClientProperty("RenderingHint.value", value); }
Example 9
Source File: VizPanel.java From ontopia with Apache License 2.0 | 5 votes |
/** * Creates search menu items. */ protected void createSearchMenuItems() { searchMenuItem = new JCheckBoxMenuItem(Messages .getString("Viz.ShowSearchBar"), searchPanelVisible); searchMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent action) { switchSearchPanel(); searchMenuItem.setSelected(searchPanelVisible); } }); add(glPopup, searchMenuItem, ITEM_ID_SHOW_SEARCH_BAR); }
Example 10
Source File: ContextMenu.java From FancyBing with GNU General Public License v3.0 | 5 votes |
private JCheckBoxMenuItem createCheckBox(String label, String actionCommand) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(i18n(label)); item.addActionListener(m_actionListener); item.setActionCommand(actionCommand); return item; }
Example 11
Source File: ReferencesBrowserControllerUI.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) { final boolean[] internalChange = new boolean[1]; menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (internalChange[0]) return; final int column = Integer.parseInt(e.getActionCommand()); if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) { BrowserUtils.performTask(new Runnable() { public void run() { final int retainedSizesState = referencesBrowserController.getReferencesControllerHandler(). getHeapFragmentWalker().computeRetainedSizes(false, true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) { internalChange[0] = true; menuItem.setSelected(!menuItem.isSelected()); internalChange[0] = false; } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); } }); } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); }
Example 12
Source File: FieldsBrowserControllerUI.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) { final boolean[] internalChange = new boolean[1]; menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (internalChange[0]) return; final int column = Integer.parseInt(e.getActionCommand()); if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) { BrowserUtils.performTask(new Runnable() { public void run() { final int retainedSizesState = fieldsBrowserController.getInstancesControllerHandler(). getHeapFragmentWalker().computeRetainedSizes(false, true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) { internalChange[0] = true; menuItem.setSelected(!menuItem.isSelected()); internalChange[0] = false; } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); } }); } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); }
Example 13
Source File: CpmPanel.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Creates JMenuItems that should be added to the File menu. * * @return a List of JMenuItems */ public List createFileMenuItems() { List menuItemList = new ArrayList(); openCpeDescMenuItem = new JMenuItem("Open CPE Descriptor"); openCpeDescMenuItem.addActionListener(this); menuItemList.add(openCpeDescMenuItem); saveCpeDescMenuItem = new JMenuItem("Save CPE Descriptor"); saveCpeDescMenuItem.addActionListener(this); menuItemList.add(saveCpeDescMenuItem); refreshMenuItem = new JMenuItem("Refresh Descriptors from File System"); refreshMenuItem.addActionListener(this); menuItemList.add(refreshMenuItem); JMenu saveOptionsSubmenu = new JMenu ("Save Options"); saveUsingImportMenuItem = new JCheckBoxMenuItem("Use <import>"); saveUsingImportMenuItem.addActionListener(this); saveUsingImportMenuItem.setSelected(saveUsingImports); saveOptionsSubmenu.add(saveUsingImportMenuItem); menuItemList.add(saveOptionsSubmenu); clearAllMenuItem = new JMenuItem("Clear All"); clearAllMenuItem.addActionListener(this); menuItemList.add(clearAllMenuItem); return menuItemList; }
Example 14
Source File: ViewMenu.java From triplea with GNU General Public License v3.0 | 5 votes |
private void addShowMapBlends() { showMapBlends = new JCheckBoxMenuItem("Show Map Blends"); showMapBlends.setMnemonic(KeyEvent.VK_B); if (uiContext.getMapData().getHasRelief() && showMapDetails.isEnabled() && showMapDetails.isSelected()) { showMapBlends.setEnabled(true); showMapBlends.setSelected(TileImageFactory.getShowMapBlends()); } else { showMapBlends.setSelected(false); showMapBlends.setEnabled(false); } showMapBlends.addActionListener( e -> { if (TileImageFactory.getShowMapBlends() == showMapBlends.isSelected()) { return; } TileImageFactory.setShowMapBlends(showMapBlends.isSelected()); TileImageFactory.setShowMapBlendMode(uiContext.getMapData().getMapBlendMode()); TileImageFactory.setShowMapBlendAlpha(uiContext.getMapData().getMapBlendAlpha()); new Thread( () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()), "Show map Blends thread") .start(); }); add(showMapBlends); }
Example 15
Source File: ClassesListControllerUI.java From netbeans with Apache License 2.0 | 5 votes |
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) { final boolean[] internalChange = new boolean[1]; menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (e.getActionCommand().equals("Filter")) { // NOI18N filterComponent.getComponent().setVisible(!filterComponent.getComponent().isVisible()); return; } if (internalChange[0]) return; final int column = Integer.parseInt(e.getActionCommand()); if (column == 4 && !classesListTableModel.isRealColumnVisible(column)) { BrowserUtils.performTask(new Runnable() { public void run() { final int retainedSizesState = classesListController.getClassesController(). getHeapFragmentWalker().computeRetainedSizes(true, true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) { internalChange[0] = true; menuItem.setSelected(!menuItem.isSelected()); internalChange[0] = false; } else { initData(); setColumnVisibility(4,true); } } }); } }); } else { setColumnVisibility(column, !classesListTableModel.isRealColumnVisible(column)); } } }); }
Example 16
Source File: ReferencesBrowserControllerUI.java From netbeans with Apache License 2.0 | 5 votes |
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) { final boolean[] internalChange = new boolean[1]; menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (internalChange[0]) return; final int column = Integer.parseInt(e.getActionCommand()); if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) { BrowserUtils.performTask(new Runnable() { public void run() { final int retainedSizesState = referencesBrowserController.getReferencesControllerHandler(). getHeapFragmentWalker().computeRetainedSizes(false, true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) { internalChange[0] = true; menuItem.setSelected(!menuItem.isSelected()); internalChange[0] = false; } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); } }); } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); }
Example 17
Source File: FieldsBrowserControllerUI.java From netbeans with Apache License 2.0 | 5 votes |
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) { final boolean[] internalChange = new boolean[1]; menuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if (internalChange[0]) return; final int column = Integer.parseInt(e.getActionCommand()); if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) { BrowserUtils.performTask(new Runnable() { public void run() { final int retainedSizesState = fieldsBrowserController.getInstancesControllerHandler(). getHeapFragmentWalker().computeRetainedSizes(false, true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) { internalChange[0] = true; menuItem.setSelected(!menuItem.isSelected()); internalChange[0] = false; } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); } }); } else { fieldsListTableModel.setRealColumnVisibility(column, !fieldsListTableModel.isRealColumnVisible(column)); fieldsListTable.createDefaultColumnsFromModel(); fieldsListTable.updateTreeTableHeader(); setColumnsData(); } } }); }
Example 18
Source File: HeapView.java From netbeans with Apache License 2.0 | 5 votes |
/** * Shows a popup at the specified location that allows you to configure the * various options. */ private void showPopup(int x, int y) { JPopupMenu popup = new JPopupMenu(); JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(NbBundle.getMessage(HeapView.class, "LBL_ShowText")); cbmi.setSelected(getShowText()); cbmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setShowText(((JCheckBoxMenuItem) e.getSource()). isSelected()); } }); popup.add(cbmi); popup.show(this, x, y); }
Example 19
Source File: BiomeProfileMenuFactory.java From amidst with GNU General Public License v3.0 | 4 votes |
private JCheckBoxMenuItem createCheckBox(BiomeProfile profile) { JCheckBoxMenuItem result = new JCheckBoxMenuItem(profile.getName()); tryCreateKeyboardShortcut(profile.getShortcut(), result); result.addActionListener(createListener(profile, result)); return result; }
Example 20
Source File: DomGui.java From DominionSim with MIT License | 4 votes |
private JMenuBar createMenu() { JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu( "File" ); fileMenu.setMnemonic( 'f' ); JMenuItem loadPool = new JMenuItem( "Import Bots", 'I' ); loadPool.addActionListener( this ); loadPool.setActionCommand( "Load" ); fileMenu.add( loadPool ); JMenuItem saveDeck = new JMenuItem( "Export Bots", 'E' ); saveDeck.addActionListener( this ); saveDeck.setActionCommand( "Save" ); fileMenu.add( saveDeck ); fileMenu.insertSeparator( 2 ); JMenuItem exit = new JMenuItem( "Exit", 'X' ); exit.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { shutDown(); } } ); fileMenu.add( exit ); bar.add( fileMenu ); JMenu devmodeMenu = new JMenu("Development"); JCheckBoxMenuItem devMode = new JCheckBoxMenuItem( "Development Mode" ); devMode.setSelected(DomEngine.developmentMode); devMode.addActionListener(this); devMode.setActionCommand("DevMode"); devmodeMenu.add(devMode); bar.add(devmodeMenu); JMenu helpMenu = new JMenu( "Help" ); helpMenu.setMnemonic( 'h' ); JMenuItem webHelp = new JMenuItem( "http://dominionsimulator.wordpress.com" ); webHelp.addActionListener( this ); webHelp.setActionCommand( "WebHelp" ); helpMenu.add( webHelp); helpMenu.insertSeparator( 2 ); JMenuItem about = new JMenuItem( "About", 't' ); about.addActionListener( this ); about.setActionCommand( "About" ); helpMenu.add( about ); bar.add( helpMenu ); return bar; }