List of usage examples for javax.swing JMenu putClientProperty
public final void putClientProperty(Object key, Object value)
From source file:org.lnicholls.galleon.gui.MainFrame.java
public MainFrame(String version) { super("Galleon " + version); setDefaultCloseOperation(0);// www .j a va 2 s . co m JMenuBar menuBar = new JMenuBar(); menuBar.putClientProperty("jgoodies.headerStyle", HeaderStyle.BOTH); menuBar.putClientProperty("jgoodies.windows.borderStyle", BorderStyle.SEPARATOR); menuBar.putClientProperty("Plastic.borderStyle", BorderStyle.SEPARATOR); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); fileMenu.add(new MenuAction("New App...", null, "", new Integer(KeyEvent.VK_N)) { public void actionPerformed(ActionEvent event) { new AddAppDialog(Galleon.getMainFrame()).setVisible(true); } }); fileMenu.addSeparator(); fileMenu.add(new MenuAction("Properties...", null, "", new Integer(KeyEvent.VK_P)) { public void actionPerformed(ActionEvent event) { new ServerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true); } }); /* fileMenu.add(new MenuAction("Galleon.tv Account...", null, "", new Integer(KeyEvent.VK_A)) { public void actionPerformed(ActionEvent event) { new DataDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true); } }); */ fileMenu.add(new MenuAction("Download Manager...", null, "", new Integer(KeyEvent.VK_D)) { public void actionPerformed(ActionEvent event) { new DownloadManagerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()) .setVisible(true); } }); fileMenu.add(new MenuAction("GoBack...", null, "", new Integer(KeyEvent.VK_G)) { public void actionPerformed(ActionEvent event) { new GoBackDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true); } }); fileMenu.add(new MenuAction("Music Player...", null, "", new Integer(KeyEvent.VK_M)) { public void actionPerformed(ActionEvent event) { new MusicPlayerDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true); } }); fileMenu.add(new MenuAction("ToGo...", null, "", new Integer(KeyEvent.VK_T)) { public void actionPerformed(ActionEvent event) { new ToGoDialog(Galleon.getMainFrame(), Galleon.getServerConfiguration()).setVisible(true); } }); fileMenu.addSeparator(); fileMenu.add(new MenuAction("Exit", null, "", new Integer(KeyEvent.VK_X)) { public void actionPerformed(ActionEvent event) { System.exit(0); } }); menuBar.add(fileMenu); JMenu tutorialMenu = new JMenu("Tutorials"); tutorialMenu.setMnemonic('T'); tutorialMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE); tutorialMenu.add(new MenuAction("Properties", null, "", new Integer(KeyEvent.VK_P)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); tutorialMenu.add(new MenuAction("Music Player", null, "", new Integer(KeyEvent.VK_M)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); tutorialMenu.addSeparator(); tutorialMenu.add(new MenuAction("Email", null, "", new Integer(KeyEvent.VK_E)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); tutorialMenu.add(new MenuAction("Music", null, "", new Integer(KeyEvent.VK_U)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); tutorialMenu.add(new MenuAction("Podcasting", null, "", new Integer(KeyEvent.VK_O)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); tutorialMenu.add(new MenuAction("ToGo", null, "", new Integer(KeyEvent.VK_T)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/88/48/"); } catch (Exception ex) { } } }); menuBar.add(tutorialMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); helpMenu.putClientProperty("jgoodies.noIcons", Boolean.TRUE); helpMenu.add(new MenuAction("Homepage", null, "", new Integer(KeyEvent.VK_H)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv"); } catch (Exception ex) { } } }); helpMenu.add(new MenuAction("Configuration", null, "", new Integer(KeyEvent.VK_C)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/view/93/52/"); } catch (Exception ex) { } } }); helpMenu.add(new MenuAction("FAQ", null, "", new Integer(KeyEvent.VK_F)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/content/section/3/47/"); } catch (Exception ex) { } } }); /* helpMenu.add(new MenuAction("TiVo Community Forum", null, "", new Integer(KeyEvent.VK_T)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://www.tivocommunity.com/tivo-vb/forumdisplay.php?f=35"); } catch (Exception ex) { } } }); */ helpMenu.add(new MenuAction("Galleon Forum", null, "", new Integer(KeyEvent.VK_G)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher.openURL("http://galleon.tv/component/option,com_joomlaboard/Itemid,26/"); } catch (Exception ex) { } } }); helpMenu.add(new MenuAction("File a bug", null, "", new Integer(KeyEvent.VK_B)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher .openURL("http://sourceforge.net/tracker/?atid=705256&group_id=126291&func=browse"); } catch (Exception ex) { } } }); helpMenu.add(new MenuAction("Request a feature", null, "", new Integer(KeyEvent.VK_E)) { public void actionPerformed(ActionEvent event) { try { BrowserLauncher .openURL("http://sourceforge.net/tracker/?atid=705259&group_id=126291&func=browse"); } catch (Exception ex) { } } }); helpMenu.addSeparator(); helpMenu.add(new MenuAction("About...", null, "", new Integer(KeyEvent.VK_A)) { public void actionPerformed(ActionEvent event) { JOptionPane .showMessageDialog( Galleon.getMainFrame(), "Galleon Version " + Tools.getVersion() + "\nJava Version " + System.getProperty("java.vm.version") + "\nPublishing Port " + Galleon.getHttpPort() + "\nApplication Port " + Galleon.getPort() + "\nhttp://galleon.tv\njavahmo@users.sourceforge.net\nCopyright \251 2005, 2006 Leon Nicholls. All Rights Reserved.", "About", JOptionPane.INFORMATION_MESSAGE); } }); menuBar.add(helpMenu); setJMenuBar(menuBar); JComponent content = createContentPane(); setContentPane(content); pack(); Dimension paneSize = getSize(); Dimension screenSize = getToolkit().getScreenSize(); setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); URL url = getClass().getClassLoader().getResource("guiicon.gif"); ImageIcon logo = new ImageIcon(url); if (logo != null) setIconImage(logo.getImage()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
From source file:processing.app.Base.java
public void rebuildBoardsMenu() throws Exception { boardsCustomMenus = new LinkedList<>(); // The first custom menu is the "Board" selection submenu JMenu boardMenu = new JMenu(tr("Board")); boardMenu.putClientProperty("removeOnWindowDeactivation", true); MenuScroller.setScrollerFor(boardMenu).setTopFixedCount(1); boardMenu.add(new JMenuItem(new AbstractAction(tr("Boards Manager...")) { public void actionPerformed(ActionEvent actionevent) { String filterText = ""; String dropdownItem = ""; if (actionevent instanceof Event) { filterText = ((Event) actionevent).getPayload().get("filterText").toString(); dropdownItem = ((Event) actionevent).getPayload().get("dropdownItem").toString(); }//from w w w .j a va2 s .co m try { openBoardsManager(filterText, dropdownItem); } catch (Exception e) { //TODO show error e.printStackTrace(); } } })); boardsCustomMenus.add(boardMenu); // If there are no platforms installed we are done if (BaseNoGui.packages.size() == 0) return; // Separate "Install boards..." command from installed boards boardMenu.add(new JSeparator()); // Generate custom menus for all platforms Set<String> customMenusTitles = new LinkedHashSet<>(); for (TargetPackage targetPackage : BaseNoGui.packages.values()) { for (TargetPlatform targetPlatform : targetPackage.platforms()) { customMenusTitles.addAll(targetPlatform.getCustomMenus().values()); } } for (String customMenuTitle : customMenusTitles) { JMenu customMenu = new JMenu(tr(customMenuTitle)); customMenu.putClientProperty("removeOnWindowDeactivation", true); boardsCustomMenus.add(customMenu); } List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>(); ButtonGroup boardsButtonGroup = new ButtonGroup(); Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>(); // Cycle through all packages boolean first = true; for (TargetPackage targetPackage : BaseNoGui.packages.values()) { // For every package cycle through all platform for (TargetPlatform targetPlatform : targetPackage.platforms()) { // Add a separator from the previous platform if (!first) boardMenu.add(new JSeparator()); first = false; // Add a title for each platform String platformLabel = targetPlatform.getPreferences().get("name"); if (platformLabel != null && !targetPlatform.getBoards().isEmpty()) { JMenuItem menuLabel = new JMenuItem(tr(platformLabel)); menuLabel.setEnabled(false); boardMenu.add(menuLabel); } // Cycle through all boards of this platform for (TargetBoard board : targetPlatform.getBoards().values()) { if (board.getPreferences().get("hide") != null) continue; JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup, buttonGroupsMap, board, targetPlatform, targetPackage); boardMenu.add(item); boardsButtonGroup.add(item); } } } if (menuItemsToClickAfterStartup.isEmpty()) { menuItemsToClickAfterStartup.add(selectFirstEnabledMenuItem(boardMenu)); } for (JMenuItem menuItemToClick : menuItemsToClickAfterStartup) { menuItemToClick.setSelected(true); menuItemToClick.getAction().actionPerformed(new ActionEvent(this, -1, "")); } }