Java Code Examples for javax.swing.JCheckBoxMenuItem#setSelected()
The following examples show how to use
javax.swing.JCheckBoxMenuItem#setSelected() .
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: PreviousPaletteAction.java From DiskBrowser with GNU General Public License v3.0 | 6 votes |
@Override public void actionPerformed (ActionEvent e) // ---------------------------------------------------------------------------------// { Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS); if (palette != null) { Enumeration<AbstractButton> enumeration = buttonGroup.getElements (); while (enumeration.hasMoreElements ()) { JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement (); if (item.getText ().equals (palette.getName ())) { item.setSelected (true); break; } } } }
Example 2
Source File: ViewMenu.java From triplea with GNU General Public License v3.0 | 6 votes |
private void addShowMapDetails() { showMapDetails = new JCheckBoxMenuItem("Show Map Details"); showMapDetails.setMnemonic(KeyEvent.VK_D); showMapDetails.setSelected(TileImageFactory.getShowReliefImages()); showMapDetails.addActionListener( e -> { if (TileImageFactory.getShowReliefImages() == showMapDetails.isSelected()) { return; } TileImageFactory.setShowReliefImages(showMapDetails.isSelected()); new Thread( () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()), "Show map details thread") .start(); }); add(showMapDetails); }
Example 3
Source File: BiomeProfileMenuFactory.java From amidst with GNU General Public License v3.0 | 6 votes |
private ActionListener createListener(final BiomeProfile profile, final JCheckBoxMenuItem selectedCheckBox) { ActionListener result = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { actions.selectBiomeProfile(profile); for (JCheckBoxMenuItem checkBox : allCheckBoxes) { checkBox.setSelected(false); } selectedCheckBox.setSelected(true); } }; if (defaultBiomeProfileSelector == null && profile.equals(BiomeProfile.getDefaultProfile())) { defaultBiomeProfileSelector = () -> result.actionPerformed(null); } return result; }
Example 4
Source File: WindowMenu.java From pumpernickel with MIT License | 6 votes |
public void run() { removeAll(); add(minimizeItem); if (customItems.length != 0) { addSeparator(); for (int a = 0; a < customItems.length; a++) { if(customItems[a]!=null) add(customItems[a]); } } addSeparator(); add(bringItem); addSeparator(); Frame[] frames = WindowList.getFrames(false, false, true); for (int a = 0; a < frames.length; a++) { JCheckBoxMenuItem item = new SummonMenuItem(frames[a]); item.setSelected(frames[a] == myFrame); add(item); } fixMenuBar(myFrame, WindowMenu.this); }
Example 5
Source File: GMLEditor.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void addTool(final Tool t, JMenu menu, JToolBar toolbar, ButtonGroup menuGroup, ButtonGroup toolbarGroup) { final JToggleButton toggle = new JToggleButton(); final JCheckBoxMenuItem check = new JCheckBoxMenuItem(); Action action = new AbstractAction(t.getName()) { @Override public void actionPerformed(ActionEvent e) { if (currentTool != null) { currentTool.deactivate(); } currentTool = t; toggle.setSelected(true); check.setSelected(true); currentTool.activate(); } }; toggle.setAction(action); check.setAction(action); menu.add(check); if (toolbar != null) { toolbar.add(toggle); toolbarGroup.add(toggle); } menuGroup.add(check); }
Example 6
Source File: ScenarioEditor.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void addTool(final Tool t, JMenu menu, JToolBar toolbar, ButtonGroup menuGroup, ButtonGroup toolbarGroup) { final JToggleButton toggle = new JToggleButton(); final JCheckBoxMenuItem check = new JCheckBoxMenuItem(); Action action = new AbstractAction(t.getName()) { @Override public void actionPerformed(ActionEvent e) { if (currentTool != null) { currentTool.deactivate(); } currentTool = t; toggle.setSelected(true); check.setSelected(true); currentTool.activate(); } }; toggle.setAction(action); check.setAction(action); menu.add(check); toolbar.add(toggle); menuGroup.add(check); toolbarGroup.add(toggle); }
Example 7
Source File: CSearchMenu.java From binnavi with Apache License 2.0 | 5 votes |
/** * Creates the Search menu. * * @param graph The graph to search through. */ public CSearchMenu(final ZyGraph graph) { super("Search"); final ZyGraphSearchSettings settings = graph.getSettings().getSearchSettings(); setMnemonic("HK_MENU_SEARCH".charAt(0)); final JCheckBoxMenuItem searchVisibleMenu = new JCheckBoxMenuItem(new CActionSearchOnlyVisibleNodes(graph)); searchVisibleMenu.setSelected(settings.getSearchVisibleNodesOnly()); add(searchVisibleMenu); final JCheckBoxMenuItem searchSelectedOnly = new JCheckBoxMenuItem(new CActionSearchOnlySelectedNodes(graph)); searchSelectedOnly.setSelected(settings.getSearchSelectedNodesOnly()); add(searchSelectedOnly); final JCheckBoxMenuItem searchCaseSensitiveMenu = new JCheckBoxMenuItem(new CActionSearchCaseSensitive(graph)); searchCaseSensitiveMenu.setSelected(settings.getSearchCaseSensitive()); add(searchCaseSensitiveMenu); final JCheckBoxMenuItem searchRegexMenu = new JCheckBoxMenuItem(new CActionSearchRegEx(graph)); searchRegexMenu.setSelected(settings.getSearchRegEx()); add(searchRegexMenu); }
Example 8
Source File: SwingSet3.java From beautyeye with Apache License 2.0 | 5 votes |
protected JMenuBar createMenuBar() { JMenuBar menubar = new JMenuBar(); menubar.setName("menubar"); // File menu JMenu fileMenu = new JMenu(); fileMenu.setName("file"); menubar.add(fileMenu); // File -> Quit if (!runningOnMac()) { JMenuItem quitItem = new JMenuItem(); quitItem.setName("quit"); quitItem.setAction(getAction("quit")); fileMenu.add(quitItem); } // View menu JMenu viewMenu = new JMenu(); viewMenu.setName("view"); // View -> Look and Feel viewMenu.add(createLookAndFeelMenu()); // View -> Source Code Visible sourceCodeCheckboxItem = new JCheckBoxMenuItem(); sourceCodeCheckboxItem.setSelected(isSourceCodeVisible()); sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem"); sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener()); viewMenu.add(sourceCodeCheckboxItem); menubar.add(viewMenu); return menubar; }
Example 9
Source File: DropdownButton.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void addAction(JPopupMenu popup, Action action) { if (action == null) { popup.addSeparator(); } else { Class cls = (Class)action.getValue(KEY_CLASS); if (Boolean.class.equals(cls)) { Boolean boolvalue = (Boolean)action.getValue(KEY_BOOLVALUE); JCheckBoxMenuItem item = new JCheckBoxMenuItem(action); item.setSelected(boolvalue); popup.add(item); } else { popup.add(action); } } }
Example 10
Source File: DropdownButton.java From netbeans with Apache License 2.0 | 5 votes |
private void addAction(JPopupMenu popup, Action action) { if (action == null) { popup.addSeparator(); } else { Class cls = (Class)action.getValue(KEY_CLASS); if (Boolean.class.equals(cls)) { Boolean boolvalue = (Boolean)action.getValue(KEY_BOOLVALUE); JCheckBoxMenuItem item = new JCheckBoxMenuItem(action); item.setSelected(boolvalue); popup.add(item); } else { popup.add(action); } } }
Example 11
Source File: LineWrap.java From Open-LaTeX-Studio with MIT License | 5 votes |
@Override public JMenuItem getMenuPresenter() { JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(WORD_WRAP,null); menuItem.addActionListener(this); menuItem.setSelected((boolean) ApplicationSettings.Setting.LINEWRAP_ENABLED.getValue()); return menuItem; }
Example 12
Source File: WrapAction.java From netbeans with Apache License 2.0 | 4 votes |
@Override public JMenuItem getPopupPresenter() { JCheckBoxMenuItem item = new JCheckBoxMenuItem(this); item.setSelected((Boolean) this.getValue(BOOLEAN_STATE_ENABLED_KEY)); return item; }
Example 13
Source File: MenuHandler.java From DiskBrowser with GNU General Public License v3.0 | 4 votes |
@Override public void restore (Preferences prefs) // ---------------------------------------------------------------------------------// { lineWrapItem.setSelected (prefs.getBoolean (PREFS_LINE_WRAP, true)); showLayoutItem.setSelected (prefs.getBoolean (PREFS_SHOW_LAYOUT, true)); showCatalogItem.setSelected (prefs.getBoolean (PREFS_SHOW_CATALOG, true)); showFreeSectorsItem.setSelected (prefs.getBoolean (PREFS_SHOW_FREE_SECTORS, false)); colourQuirksItem.setSelected (prefs.getBoolean (PREFS_COLOUR_QUIRKS, false)); monochromeItem.setSelected (prefs.getBoolean (PREFS_MONOCHROME, false)); switch (prefs.getInt (PREFS_SCALE, 2)) { case 1: scale1Item.doClick (); break; case 2: scale2Item.doClick (); break; case 3: scale3Item.doClick (); break; } // debuggingItem.setSelected (prefs.getBoolean (PREFS_DEBUGGING, false)); splitRemarkItem.setSelected (prefs.getBoolean (PREFS_SPLIT_REMARKS, false)); alignAssignItem.setSelected (prefs.getBoolean (PREFS_ALIGN_ASSIGN, true)); showCaretItem.setSelected (prefs.getBoolean (PREFS_SHOW_CARET, false)); showHeaderItem.setSelected (prefs.getBoolean (PREFS_SHOW_HEADER, true)); showBasicTargetsItem.setSelected (prefs.getBoolean (PREFS_SHOW_TARGETS, false)); onlyShowTargetLinesItem .setSelected (prefs.getBoolean (PREFS_ONLY_SHOW_TARGETS, false)); showAssemblerTargetsItem .setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_TARGETS, true)); showAssemblerStringsItem .setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_STRINGS, true)); showAssemblerHeaderItem .setSelected (prefs.getBoolean (PREFS_SHOW_ASSEMBLER_HEADER, true)); prodosSortDirectoriesItem .setSelected (prefs.getBoolean (PREFS_PRODOS_SORT_DIRECTORIES, true)); setBasicPreferences (); setAssemblerPreferences (); setProdosPreferences (); int paletteIndex = prefs.getInt (PREFS_PALETTE, 0); PaletteFactory paletteFactory = HiResImage.getPaletteFactory (); paletteFactory.setCurrentPalette (paletteIndex); Palette palette = paletteFactory.getCurrentPalette (); Enumeration<AbstractButton> enumeration = paletteGroup.getElements (); while (enumeration.hasMoreElements ()) { JCheckBoxMenuItem item = (JCheckBoxMenuItem) enumeration.nextElement (); if (item.getText ().equals (palette.getName ())) { item.setSelected (true); break; } } HiResImage.setDefaultColourQuirks (colourQuirksItem.isSelected ()); HiResImage.setDefaultMonochrome (monochromeItem.isSelected ()); VisicalcFile.setDefaultDebug (debuggingItem.isSelected ()); fontAction.restore (prefs); }
Example 14
Source File: JMenuTags.java From jeveassets with GNU General Public License v2.0 | 4 votes |
@Override public void updateMenuData() { tagsTypes = menuData.getTags(); boolean valid = !tagsTypes.isEmpty(); removeAll(); //Add New add(jNew); jNew.setEnabled(valid); //All Tags Set<Tag> allTags = new TreeSet<Tag>(GlazedLists.comparableComparator()); allTags.addAll(Settings.get().getTags().values()); //Separator if (!allTags.isEmpty()) { addSeparator(); } //Add To JCheckBoxMenuItem jCheckMenuItem; for (Tag tag : allTags) { Integer count = menuData.getTagCount().get(tag); if (count == null) { count = 0; } boolean selected = count == tagsTypes.size() && valid; if (selected) { count = 0; } jCheckMenuItem = new JTagCheckMenuItem(tag, count); if (selected) { jCheckMenuItem.setIcon(new TagIcon(tag.getColor(), true)); } else { jCheckMenuItem.setIcon(new TagIcon(tag.getColor())); } jCheckMenuItem.addActionListener(listener); jCheckMenuItem.setSelected(selected); jCheckMenuItem.setEnabled(valid); add(jCheckMenuItem); } }
Example 15
Source File: SpectraIdentificationResultsWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public SpectraIdentificationResultsWindow() { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(new Dimension(1400, 900)); getContentPane().setLayout(new BorderLayout()); setTitle("Processing..."); pnGrid = new JPanel(); // any number of rows pnGrid.setLayout(new GridLayout(0, 1, 0, 0)); pnGrid.setBackground(Color.WHITE); pnGrid.setAutoscrolls(false); noMatchesFound = new JLabel("I'm working on it", SwingConstants.CENTER); noMatchesFound.setFont(headerFont); // yellow noMatchesFound.setForeground(new Color(0xFFCC00)); pnGrid.add(noMatchesFound, BorderLayout.CENTER); // Add the Windows menu JMenuBar menuBar = new JMenuBar(); menuBar.add(new WindowsMenu()); // set font size of chart JMenuItem btnSetup = new JMenuItem("Setup dialog"); btnSetup.addActionListener(e -> { if (MZmineCore.getConfiguration() .getModuleParameters(SpectraIdentificationResultsModule.class) .showSetupDialog(this, true) == ExitCode.OK) { showExportButtonsChanged(); } }); menuBar.add(btnSetup); JCheckBoxMenuItem cbCoupleZoomY = new JCheckBoxMenuItem("Couple y-zoom"); cbCoupleZoomY.setSelected(true); cbCoupleZoomY.addItemListener(e -> setCoupleZoomY(cbCoupleZoomY.isSelected())); menuBar.add(cbCoupleZoomY); JMenuItem btnSetFont = new JMenuItem("Set chart font"); btnSetFont.addActionListener(e -> setChartFont()); menuBar.add(btnSetFont); setJMenuBar(menuBar); scrollPane = new JScrollPane(pnGrid); getContentPane().add(scrollPane, BorderLayout.CENTER); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setViewportView(pnGrid); totalMatches = new ArrayList<>(); matchPanels = new HashMap<>(); setCoupleZoomY(true); setVisible(true); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); validate(); repaint(); }
Example 16
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; }
Example 17
Source File: MultiMSMSWindow.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(title); item.setSelected(state); item.addItemListener(il); menu.add(item); }
Example 18
Source File: MultiMSMSWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(title); item.setSelected(state); item.addItemListener(il); menu.add(item); }
Example 19
Source File: DockableMenu.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
void fill() { removeAll(); DockableState[] dockables = dockingContext.getDesktopList().get(0).getDockables(); List<DockableState> sorted = new LinkedList<>(); sorted.addAll(Arrays.asList(dockables)); sorted.sort(Comparator.comparing(o -> o.getDockable().getDockKey().getName())); for (final DockableState state : sorted) { if (state.getDockable() instanceof DummyDockable) { continue; } DockKey dockKey = state.getDockable().getDockKey(); String keyName = dockKey.getKey(); boolean cont = false; for (String prefix : HIDE_IN_DOCKABLE_MENU_PREFIX_REGISTRY) { if (keyName.startsWith(prefix)) { cont = true; break; } } if (cont) { continue; } String description = null; if (dockKey instanceof ResourceDockKey) { description = ((ResourceDockKey) dockKey).getShortDescription(); } description = description != null ? description : ""; String text = dockKey.getName(); if (SystemInfoUtilities.getOperatingSystem() != OperatingSystem.OSX) { // OS X cannot use html in menus so only do it for other OS text = String.format(DOCKABLE_HTML, dockKey.getName(), description); } JCheckBoxMenuItem item = new JCheckBoxMenuItem(text, dockKey.getIcon()); item.setSelected(!state.isClosed()); item.addActionListener(e -> toggleState(state)); // special handling for results overview dockable in Results perspective // and process view dockable in Design perspective // these dockables are not allowed to be closed so we disable this item while in respective perspective String perspectiveName = RapidMinerGUI.getMainFrame().getPerspectiveController().getModel().getSelectedPerspective().getName(); if ((PerspectiveModel.RESULT.equals(perspectiveName) && ResultDisplay.RESULT_DOCK_KEY.equals(keyName)) || (PerspectiveModel.DESIGN.equals(perspectiveName) && ProcessPanel.PROCESS_PANEL_DOCK_KEY.equals(keyName))) { item.setEnabled(false); item.setToolTipText(I18N.getGUIMessage("gui.label.dockable.unclosable.tip")); } add(item); ensurePopupHeight(); } }
Example 20
Source File: CGraphMenu.java From binnavi with Apache License 2.0 | 2 votes |
/** * Creates the Graph submenu. * * @param parent Window for which the menu bar is created. * @param graph Graph shown in the graph panel for which the menu bar is created. * @param container Context in which the graph was opened. * @param autoLayoutMenu Menu to enable and disable automated layouting. * @param proximityBrowsingMenu Menu to enable and disable proximity browsing. */ public CGraphMenu(final CGraphWindow parent, final ZyGraph graph, final IViewContainer container, final JCheckBoxMenuItem proximityBrowsingMenu, final JCheckBoxMenuItem autoLayoutMenu) { super("Graph"); final ZyGraphViewSettings settings = graph.getSettings(); setMnemonic("HK_MENU_GRAPH".charAt(0)); autoLayoutMenu.setSelected(settings.getLayoutSettings().getAutomaticLayouting()); add(autoLayoutMenu); proximityBrowsingMenu.setSelected(settings.getProximitySettings().getProximityBrowsing()); add(proximityBrowsingMenu); addSeparator(); add(CActionProxy.proxy(new CActionGraphSettings(parent, graph))); add(CActionProxy.proxy( new CActionShowProximityBrowsingSettingsDialog(parent, graph.getSettings()))); addSeparator(); add(CActionProxy.proxy(new CActionInsertView(parent, graph, container))); addSeparator(); add(CActionProxy.proxy(new CActionDeleteSelectedNodes(graph, false))); add(CActionProxy.proxy(new CActionDeleteUnselectedNodes(graph))); add(CActionProxy.proxy(new CActionDeleteInvisibleNodes(graph))); addSeparator(); final JMenu transformMenu = new JMenu("Transform"); transformMenu.add(CActionProxy.proxy(new CActionInlineAll(parent, container, graph))); if ((container instanceof CModuleContainer) || (container instanceof CProjectContainer)) { transformMenu.addSeparator(); transformMenu.add(CActionProxy.proxy(new CActionShowReil( parent, container, container.getModules().get(0), graph.getRawView()))); } transformMenu.add(CActionProxy.proxy( new CActionShowDataflow(parent, container, graph.getRawView()))); add(transformMenu); }