Java Code Examples for javax.swing.JMenu#addSeparator()
The following examples show how to use
javax.swing.JMenu#addSeparator() .
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: FigureWidget.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void addFigureToSubMenu(JMenu subMenu, final Figure f, boolean successor, int depth) { Set<Figure> set = f.getPredecessorSet(); if (successor) { set = f.getSuccessorSet(); } int count = set.size(); if (set.contains(f)) { count--; } for (Figure f2 : set) { if (f2 == f) { continue; } count--; addFigureToMenu(subMenu, f2, successor, depth - 1); if (count > 0) { subMenu.addSeparator(); } } }
Example 2
Source File: CEventListTableMenu.java From binnavi with Apache License 2.0 | 6 votes |
/** * Adds the sub menu that is makes it possible to combine multiple traces into one trace. * * @param parent Parent window used for dialogs. * @param traceProvider Trace provider that provides the trace information shown in the table. * @param selectedRows Table row indices of the selected traces. */ private void addCombineMenu( final JFrame parent, final ITraceListProvider traceProvider, final int[] selectedRows) { addSeparator(); final JMenu combineMenu = new JMenu("Combine Traces"); final List<TraceList> traces = getTraces(traceProvider, selectedRows); combineMenu.add(CActionProxy.proxy(new CActionCombineTraces(parent, traceProvider, traces))); combineMenu.add(CActionProxy.proxy(new CActionIntersectTraces(parent, traceProvider, traces))); if (traces.size() == 2) { combineMenu.addSeparator(); combineMenu.add(CActionProxy.proxy( new CActionDifferenceTraces(parent, traceProvider, traces.get(0), traces.get(1)))); combineMenu.add(CActionProxy.proxy( new CActionDifferenceTraces(parent, traceProvider, traces.get(1), traces.get(0)))); } add(combineMenu); }
Example 3
Source File: PlaceMenu.java From arcusplatform with Apache License 2.0 | 6 votes |
@SuppressWarnings("serial") @Override protected JMenu createComponent() { JMenu menu = new JMenu(label); addPlace = placeController.actionAddPlace(); deletePlace = placeController.actionDeletePlace(); selectPlace = new AbstractAction("Select Place") { @Override public void actionPerformed(ActionEvent e) { PlaceMenu.this.placeController.promptForSelectPlace(). onSuccess((p) -> { PlaceMenu.this.placeController.selectPlace(p); }); } }; validateAddress = placeController.actionValidateAddress(); menu.add(addPlace); menu.addSeparator(); menu.add(deletePlace); menu.addSeparator(); menu.add(selectPlace); menu.addSeparator(); menu.add(validateAddress); return menu; }
Example 4
Source File: FigureWidget.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void addFigureToSubMenu(JMenu subMenu, final Figure f, boolean successor, int depth) { Set<Figure> set = f.getPredecessorSet(); if (successor) { set = f.getSuccessorSet(); } int count = set.size(); if (set.contains(f)) { count--; } for (Figure f2 : set) { if (f2 == f) { continue; } count--; addFigureToMenu(subMenu, f2, successor, depth - 1); if (count > 0) { subMenu.addSeparator(); } } }
Example 5
Source File: FigureWidget.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void addFigureToSubMenu(JMenu subMenu, final Figure f, boolean successor, int depth) { Set<Figure> set = f.getPredecessorSet(); if (successor) { set = f.getSuccessorSet(); } int count = set.size(); if (set.contains(f)) { count--; } for (Figure f2 : set) { if (f2 == f) { continue; } count--; addFigureToMenu(subMenu, f2, successor, depth - 1); if (count > 0) { subMenu.addSeparator(); } } }
Example 6
Source File: OperatorMenu.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
/** * Creates the default menu. * * @return The menu */ public JMenuBar createDefaultMenu() { JMenu fileMenu = new JMenu("File"); fileMenu.add(loadParametersAction); fileMenu.add(saveParametersAction); fileMenu.addSeparator(); fileMenu.add(displayParametersAction); JMenu helpMenu = new JMenu("Help"); helpMenu.add(createHelpMenuItem()); helpMenu.add(aboutAction); final JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; }
Example 7
Source File: MetalworksFrame.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
Example 8
Source File: MetalworksFrame.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
Example 9
Source File: MetalworksFrame.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
Example 10
Source File: FileMenuProvider.java From gcs with Mozilla Public License 2.0 | 5 votes |
public static JMenu createMenu() { JMenu menu = new JMenu(I18n.Text("File")); JMenu newMenu = new JMenu(I18n.Text("New File…")); newMenu.add(new DynamicMenuItem(NewCharacterSheetCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewCharacterTemplateCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewAdvantagesLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewAdvantageModifiersLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewEquipmentLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewEquipmentModifiersLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewNoteLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewSkillsLibraryCommand.INSTANCE)); newMenu.add(new DynamicMenuItem(NewSpellsLibraryCommand.INSTANCE)); menu.add(newMenu); menu.add(new DynamicMenuItem(OpenCommand.INSTANCE)); menu.add(new RecentFilesMenu()); menu.add(new DynamicMenuItem(CloseCommand.INSTANCE)); menu.addSeparator(); menu.add(new DynamicMenuItem(SaveCommand.INSTANCE)); menu.add(new DynamicMenuItem(SaveAsCommand.INSTANCE)); menu.add(new ExportMenu()); menu.addSeparator(); menu.add(new DynamicMenuItem(PageSetupCommand.INSTANCE)); menu.add(new DynamicMenuItem(PrintCommand.INSTANCE)); if (!Platform.isMacintosh()) { menu.addSeparator(); menu.add(new DynamicMenuItem(QuitCommand.INSTANCE)); } DynamicMenuEnabler.add(newMenu); DynamicMenuEnabler.add(menu); return menu; }
Example 11
Source File: JavaKit.java From netbeans with Apache License 2.0 | 5 votes |
protected void addAction(JTextComponent target, JMenu menu, String actionName) { BaseKit kit = Utilities.getKit(target); if (kit == null) return; Action a = kit.getActionByName(actionName); if (a!=null){ addAction(target, menu, a); } else { // action-name is null, add the separator menu.addSeparator(); } }
Example 12
Source File: Window.java From lippen-network-tool with Apache License 2.0 | 5 votes |
private void initMenu() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("设置(O)"); menu.setMnemonic('O'); JMenu m = new JMenu("编码设置(E)"); ButtonGroup group = new ButtonGroup(); for (String[] charset : charsets) { if (charset.length == 0) { m.addSeparator(); continue; } CharsetCheckBoxMenuItem item = new CharsetCheckBoxMenuItem(charset[0], charset[1]); if (charset[1].equals(DEFAULT_CHARSET.name())) { item.setSelected(true); } item.addActionListener(listener); group.add(item); m.add(item); } menu.add(m); JMenu about = new JMenu("关于"); menuBar.add(menu); menuBar.add(about); this.setJMenuBar(menuBar); }
Example 13
Source File: ShuffleMenuBar.java From Shuffle-Move with GNU General Public License v3.0 | 5 votes |
private void setupFileMenu() { JMenu menu = new JMenu(getString(KEY_FILE)); menu.setMnemonic(KeyEvent.VK_F); registerAbstractButton(menu, () -> getString(KEY_FILE)); MenuAction load = new MenuAction(() -> getString(KEY_LOAD), e -> getUser().loadAll()); load.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.CTRL_MASK)); addMenuAction(menu, load); MenuAction saveAction = new MenuAction(() -> getString(KEY_SAVE), e -> getUser().saveAll()); saveAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); addMenuAction(menu, saveAction); menu.addSeparator(); MenuAction importAction = new MenuAction(() -> getString(KEY_IMPORT), e -> BaseServiceManager.launchServiceByClass(MigrateService.class, getUser(), getOwner())); addMenuAction(menu, importAction); menu.addSeparator(); MenuAction exitAction = new MenuAction(() -> getString(KEY_EXIT), e -> getOwner().dispatchEvent( new WindowEvent(getOwner(), WindowEvent.WINDOW_CLOSING))); addMenuAction(menu, exitAction); add(menu); }
Example 14
Source File: PCGenMenuBar.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private JMenu createToolsMenu() { JMenu menu = new JMenu(); menu.setText(LanguageBundle.getString("in_mnuTools")); menu.add(new JMenuItem(actionMap.get(PCGenActionMap.PREFERENCES_COMMAND))); menu.addSeparator(); menu.add(new JMenuItem(actionMap.get(PCGenActionMap.LOG_COMMAND))); menu.add(new LoggingLevelMenu()); menu.add(new JMenuItem(actionMap.get(PCGenActionMap.CALCULATOR_COMMAND))); menu.add(new JMenuItem(actionMap.get(PCGenActionMap.COREVIEW_COMMAND))); menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOLVERVIEW_COMMAND))); return menu; }
Example 15
Source File: MetalworksFrame.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
Example 16
Source File: ComponentSource.java From LoboBrowser with MIT License | 5 votes |
public JMenu getHelpMenu() { final JMenu menu = new JMenu("Help"); menu.setMnemonic('H'); menu.add(menuItem("About LoboBrowser", 'A', this.actionPool.aboutAction)); menu.addSeparator(); menu.add(menuItem("Project Home Page", this.actionPool.createNavigateAction("https://lobobrowser.com"))); return menu; }
Example 17
Source File: ComponentSource.java From LoboBrowser with MIT License | 5 votes |
public JMenu getNavigationMenu() { final JMenu menu = new JMenu("Navigation"); menu.setMnemonic('N'); if (LoboBrowser.OS_NAME == OS.MAC) { menu.add(menuItem("Back", 'B', KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, CMD_CTRL_KEY_MASK), this.actionPool.backAction)); menu.add( menuItem("Forward", 'F', KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, CMD_CTRL_KEY_MASK), this.actionPool.forwardAction)); menu.add(menuItem("Stop", 'S', KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), this.actionPool.stopAction)); } else { menu.add(menuItem("Back", 'B', "ctrl B", this.actionPool.backAction)); menu.add(menuItem("Forward", 'F', this.actionPool.forwardAction)); menu.add(menuItem("Stop", 'S', KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), this.actionPool.stopAction)); } final JMenuItem reloadMenuItem = menuItem("Reload", 'R', KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), this.actionPool.reloadAction); reloadMenuItem.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ctrl R"), "reload action"); reloadMenuItem.getActionMap().put("reload action", this.actionPool.reloadAction); menu.add(reloadMenuItem); menu.addSeparator(); menu.add(this.backMoreMenu); menu.add(this.forwardMoreMenu); menu.add(this.recentHostsMenu); return menu; }
Example 18
Source File: SessionMenu.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override protected JMenu createComponent() { JMenu menu = new JMenu(label); menu.add(new JMenuItem(controller.getChangePasswordAction())); menu.add(new JMenuItem(controller.getReconnectAction())); menu.addSeparator(); menu.add(new JMenuItem(controller.getLaunchBrowser())); menu.addSeparator(); menu.add(new JMenuItem(controller.getLogoutAndLoginAction())); menu.add(new JMenuItem(controller.getLogoutAndQuitAction())); menu.add(new JMenuItem(controller.getQuitAction())); return menu; }
Example 19
Source File: MainWindow.java From Creatures with GNU General Public License v2.0 | 4 votes |
private void initUI(WorldView view) { JPanel rightContainer = new JPanel(); rightContainer.setLayout(new BoxLayout(rightContainer, BoxLayout.PAGE_AXIS)); textLabel = new JLabel("Creatures"); textLabel.setAlignmentX(Component.LEFT_ALIGNMENT); speedLabel = new JLabel("Speed"); speedLabel.setAlignmentX(Component.LEFT_ALIGNMENT); speedSlider = new JSlider(0, 15, 1); speedSlider.setAlignmentX(Component.LEFT_ALIGNMENT); speedSlider.setMajorTickSpacing(5); speedSlider.setMinorTickSpacing(1); speedSlider.setSnapToTicks(true); speedSlider.setPaintLabels(true); speedSlider.setPaintTicks(true); speedSlider.addChangeListener(this); JPanel maxFoodContainer = new JPanel(); maxFoodContainer.setLayout(new FlowLayout(FlowLayout.LEFT)); maxFoodContainer.setAlignmentX(Component.LEFT_ALIGNMENT); maxFoodLabel = new JLabel("Max Food"); SpinnerModel maxFoodSpinnerModel = new SpinnerNumberModel(WorldModel.maxFoodAmount, 0, 100000, 1); maxFoodSpinner = new JSpinner(maxFoodSpinnerModel); maxFoodSpinner.setEditor(new JSpinner.NumberEditor(maxFoodSpinner, "#")); maxFoodSpinner.addChangeListener(this); maxFoodContainer.add(maxFoodLabel); maxFoodContainer.add(maxFoodSpinner); rightContainer.add(textLabel); rightContainer.add(Box.createVerticalStrut(10)); rightContainer.add(speedLabel); rightContainer.add(speedSlider); rightContainer.add(maxFoodContainer); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, view, rightContainer); splitPane.setResizeWeight(0.8); add(splitPane); menuBar = new JMenuBar(); fileMenu = new JMenu("File"); exportStatisticsItem = new JMenuItem("Export Statistics"); exportStatisticsItem.addActionListener(this); closeItem = new JMenuItem("Close"); closeItem.addActionListener(this); fileMenu.add(exportStatisticsItem); fileMenu.addSeparator(); fileMenu.add(closeItem); worldMenu = new JMenu("Creation"); createWorldItem = new JMenuItem("Create World"); createWorldItem.addActionListener(this); worldMenu.add(createWorldItem); worldMenu.addSeparator(); createCreatureItem = new JMenuItem("Create Creature"); createCreatureItem.addActionListener(this); worldMenu.add(createCreatureItem); createCreaturesItem = new JMenuItem("Create Creatures"); createCreaturesItem.addActionListener(this); worldMenu.add(createCreaturesItem); statisticsMenu = new JMenu("Statistics"); showStatisticsItem = new JMenuItem("Show Statistics"); showStatisticsItem.addActionListener(this); statisticsMenu.add(showStatisticsItem); menuBar.add(fileMenu); menuBar.add(worldMenu); menuBar.add(statisticsMenu); setJMenuBar(menuBar); }
Example 20
Source File: ShuffleMenuBar.java From Shuffle-Move with GNU General Public License v3.0 | 4 votes |
private void setupGridMenu() { JMenu menu = new JMenu(getString(KEY_GRID)); menu.setMnemonic(KeyEvent.VK_G); buttonToi18nKeyMap.put(menu, () -> getString(KEY_GRID)); MenuAction clearAction = new MenuAction(() -> getString(KEY_CLEAR), e -> getUser().clearGrid()); clearAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.CTRL_MASK)); addMenuAction(menu, clearAction); MenuAction deleteSpeciesAction = new MenuAction(() -> getString(KEY_DELETE_SPECIES), e -> getUser().clearSelectedTiles()); deleteSpeciesAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); addMenuAction(menu, deleteSpeciesAction); MenuAction fillAction = new MenuAction(() -> getString(KEY_FILL), e -> getUser().fillGrid()); fillAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)); addMenuAction(menu, fillAction); menu.addSeparator(); MenuAction loadDefaultAction = new MenuAction(() -> getString(KEY_LOAD_DEFAULT), e -> getUser().loadDefaultGrid()); addMenuAction(menu, loadDefaultAction); MenuAction loadAction = new MenuAction(() -> getString(KEY_LOAD), e -> getUser().loadGrid()); addMenuAction(menu, loadAction); MenuAction saveAction = new MenuAction(() -> getString(KEY_SAVE), e -> getUser().saveGrid()); addMenuAction(menu, saveAction); menu.addSeparator(); MenuAction printAction = new MenuAction(() -> getString(KEY_GRID_PRINT), e -> getUser().printGrid()); printAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); addMenuAction(menu, printAction); MenuAction printConfigAction = new MenuAction(() -> getString(KEY_GRID_PRINT_CONFIG), e -> BaseServiceManager.launchServiceByClass(GridPrintConfigService.class, getUser(), getOwner())); addMenuAction(menu, printConfigAction); menu.addSeparator(); MenuAction changeModeAction = new MenuAction(() -> getString(KEY_CHANGE_MODE), e -> getUser().changeMode()); changeModeAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, ActionEvent.CTRL_MASK)); addMenuAction(menu, changeModeAction); add(menu); }