List of usage examples for javax.swing JMenu setName
public void setName(String name)
From source file:fedroot.dacs.swingdemo.DacsSingleFrameApplication.java
private JMenu createMenu(String menuName, String[] actionNames) { JMenu menu = new JMenu(); menu.setName(menuName); for (String actionName : actionNames) { JMenuItem menuItem = new JMenuItem(); menuItem.setAction(actionMap().get(actionName)); menu.add(menuItem);/*from ww w . ja v a 2 s. com*/ } return menu; }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * Get the context menu./* w w w . ja v a 2 s. co m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { JMenu menu = new JMenu("Context"); menu.setName("Context"); JMenuItem facetItem = new JMenuItem("Facets"); facetItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); menu.add(facetItem); JMenuItem digestItem = new JMenuItem("Digest"); digestItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityDigestDisplay edp = new JEntityDigestDisplay(); String edpLocator$ = edp.getLocator(); edpLocator$ = Locator.append(edpLocator$, Entigrator.ENTIHOME, entihome$); edpLocator$ = Locator.append(edpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, edpLocator$); } }); menu.add(digestItem); return menu; }
From source file:com.haulmont.cuba.desktop.sys.MenuBuilder.java
private void createMenuBarItem(JMenuBar menuBar, MenuItem item) { String caption = menuConfig.getItemCaption(item.getId()); if (!item.getChildren().isEmpty() || item.isMenu()) { final JMenu jMenu = new JMenu(caption); jMenu.addMenuListener(new MenuListener() { @Override//w w w. j a v a 2 s . com public void menuSelected(MenuEvent e) { jMenu.requestFocus(); } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); jMenu.setName(item.getId()); menuBar.add(jMenu); createSubMenu(jMenu, item); } else { JMenuItem jMenuItem = new JMenuItem(caption); jMenuItem.setName(item.getId()); //todo remove hardcoded border jMenuItem.setBorder(BorderFactory.createEmptyBorder(1, 4, 2, 4)); assignShortcut(jMenuItem, item); jMenuItem.setMaximumSize( new Dimension(jMenuItem.getPreferredSize().width, jMenuItem.getMaximumSize().height)); assignCommand(jMenuItem, item); menuBar.add(jMenuItem); } }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
/** * Get the context menu./*w w w . j ava 2s .c o m*/ * @return the context menu. */ @Override public JMenu getContextMenu() { JMenu menu = new JMenu("Context"); menu.setName("Context"); JMenuItem facetItem = new JMenuItem("Facets"); facetItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); menu.add(facetItem); JMenuItem structureItem = new JMenuItem("Structure"); structureItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityStructurePanel esp = new JEntityStructurePanel(); String espLocator$ = esp.getLocator(); espLocator$ = Locator.append(espLocator$, Entigrator.ENTIHOME, entihome$); espLocator$ = Locator.append(espLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, espLocator$); } }); menu.add(structureItem); JMenuItem refreshItem = new JMenuItem("Refresh"); refreshItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Properties locator = Locator.toProperties(locator$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JEntityDigestDisplay edp = new JEntityDigestDisplay(); String edpLocator$ = edp.getLocator(); edpLocator$ = Locator.append(edpLocator$, Entigrator.ENTIHOME, entihome$); if (selection$ != null) edpLocator$ = Locator.append(edpLocator$, SELECTION, Locator.compressText(selection$)); edpLocator$ = Locator.append(edpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, edpLocator$); } }); menu.add(refreshItem); return menu; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private JMenu buildEditMenu() { JMenu mnuEdit = new JMenu(); mnuEdit.setName("mnuEdit"); String[] editMenuActions = { "copy", "paste", "-", "selectAll", "-", "copySelectedWithHeaders" }; MenuBuilder.buildMenu(mnuEdit, editMenuActions, _actionMap); return mnuEdit; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private JMenu buildSearchMenu() { JMenu mnuSearch = new JMenu(); mnuSearch.setName("mnuSearch"); String[] seachMenuActions = { "find", "findNext" }; MenuBuilder.buildMenu(mnuSearch, seachMenuActions, _actionMap); return mnuSearch; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
/** * Builds and returns the View menu.//w w w . ja v a2s. co m * * @return a new JMenu ready to be added to the menu bar. */ private JMenu buildViewMenu() { JMenu mnuView = new JMenu(); mnuView.setName("mnuView"); String[] viewMenuActions = { "newTreeView", "newGridView", "-", "viewCharacterEditor", "viewTaxonEditor", "-", "viewActionSets", "viewImageSettings" }; MenuBuilder.buildMenu(mnuView, viewMenuActions, _actionMap); return mnuView; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private JMenuBar buildMenus() { JMenuBar menuBar = new JMenuBar(); // File menu. This on is kind of special, in that it gets rebuilt each // time a file is opened. _fileMenu = new JMenu(); _fileMenu.setName("mnuFile"); buildFileMenu(_fileMenu);//from www . j a v a 2 s . c o m menuBar.add(_fileMenu); // Edit Menu JMenu mnuEdit = buildEditMenu(); menuBar.add(mnuEdit); // Search Menu JMenu mnuSearch = buildSearchMenu(); menuBar.add(mnuSearch); // View Menu JMenu mnuView = buildViewMenu(); menuBar.add(mnuView); // Window menu _windowMenu = new JMenu(); _windowMenu.setName("mnuWindow"); buildWindowMenu(_windowMenu); menuBar.add(_windowMenu); JMenu mnuHelp = new JMenu(); mnuHelp.setName("mnuHelp"); JMenuItem mnuItHelpContents = new JMenuItem(); mnuItHelpContents.setName("mnuItHelpContents"); mnuHelp.add(mnuItHelpContents); mnuItHelpContents.addActionListener(_helpController.helpAction()); JMenuItem mnuItHelpOnSelection = new JMenuItem(IconHelper.createImageIcon("help_cursor.png")); mnuItHelpOnSelection.setName("mnuItHelpOnSelection"); mnuItHelpOnSelection.addActionListener(_helpController.helpOnSelectionAction()); mnuHelp.add(mnuItHelpOnSelection); javax.swing.Action openAboutAction = _actionMap.get("openAbout"); if (isMac()) { configureMacAboutBox(openAboutAction); } else { JMenuItem mnuItAbout = new JMenuItem(); mnuItAbout.setAction(openAboutAction); mnuHelp.addSeparator(); mnuHelp.add(mnuItAbout); } menuBar.add(mnuHelp); return menuBar; }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private void buildWindowMenu(JMenu mnuWindow) { mnuWindow.removeAll();//from w w w .j av a 2s.c om JMenuItem mnuItCascade = new JMenuItem(); mnuItCascade.setAction(_actionMap.get("cascadeFrames")); mnuWindow.add(mnuItCascade); JMenuItem mnuItTile = new JMenuItem(); mnuItTile.setAction(_actionMap.get("tileFrames")); mnuWindow.add(mnuItTile); JMenuItem mnuItTileHorz = new JMenuItem(); mnuItTileHorz.setAction(_actionMap.get("tileFramesHorizontally")); mnuWindow.add(mnuItTileHorz); JMenuItem mnuItArrangeIcons = new JMenuItem(); mnuItArrangeIcons.setAction(_actionMap.get("arrangeIcons")); mnuWindow.add(mnuItArrangeIcons); JMenuItem mnuItCloseAll = new JMenuItem(); mnuItCloseAll.setAction(_actionMap.get("closeAllFrames")); mnuWindow.add(mnuItCloseAll); mnuWindow.addSeparator(); JMenuItem mnuItChooseFont = new JMenuItem(); mnuItChooseFont.setAction(_actionMap.get("chooseFont")); mnuWindow.add(mnuItChooseFont); mnuWindow.addSeparator(); JMenu mnuLF = new JMenu(); mnuLF.setName("mnuLF"); mnuLF.setText(_resourceMap.getString("mnuLF.text")); mnuWindow.add(mnuLF); JMenuItem mnuItMetalLF = new JMenuItem(); mnuItMetalLF.setAction(_actionMap.get("metalLookAndFeel")); mnuLF.add(mnuItMetalLF); JMenuItem mnuItWindowsLF = new JMenuItem(); mnuItWindowsLF.setAction(_actionMap.get("systemLookAndFeel")); mnuLF.add(mnuItWindowsLF); try { // Nimbus L&F was added in update java 6 update 10. Class.forName("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel").newInstance(); JMenuItem mnuItNimbusLF = new JMenuItem(); mnuItNimbusLF.setAction(_actionMap.get("nimbusLookAndFeel")); mnuLF.add(mnuItNimbusLF); } catch (Exception e) { // The Nimbus L&F is not available, no matter. } mnuWindow.addSeparator(); int i = 1; for (final JInternalFrame frame : _frames) { JMenuItem windowItem = new JCheckBoxMenuItem(); if (i < 10) { windowItem.setText(String.format("%d %s", i, frame.getTitle())); windowItem.setMnemonic(KeyEvent.VK_1 + (i - 1)); } else { windowItem.setText(frame.getTitle()); } windowItem.setSelected(frame.isSelected()); windowItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { frame.setSelected(true); } catch (PropertyVetoException e1) { } } }); mnuWindow.add(windowItem); ++i; } }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Build the re-execute menu//from w w w . j av a2 s . c o m * * @param actionMap * The action map for the main GUI window * @return The JMenu for the re-execute menu */ private JMenu buildReExecuteMenu(ActionMap actionMap) { JMenu mnuReExecute = new JMenu(); mnuReExecute.setName("mnuReExecute"); JMenuItem mnuItReExecute = new JMenuItem(); mnuItReExecute.setAction(actionMap.get("mnuItReExecute")); mnuReExecute.add(mnuItReExecute); return mnuReExecute; }