List of usage examples for javax.swing JMenu getText
public String getText()
From source file:processing.app.Base.java
private JMenu getBoardCustomMenu(String label) throws Exception { for (JMenu menu : boardsCustomMenus) { if (label.equals(menu.getText())) { return menu; }//from w ww. j a v a 2s. com } throw new Exception("Custom menu not found!"); }
From source file:processing.app.Editor.java
protected JMenu buildToolsMenu() throws Exception { toolsMenu = new JMenu(_("Tools")); addInternalTools(toolsMenu);//from ww w . j ava 2 s . c o m JMenuItem item = newJMenuItemShift(_("Serial Monitor"), 'M'); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleSerial(); } }); toolsMenu.add(item); addTools(toolsMenu, BaseNoGui.getToolsFolder()); File sketchbookTools = new File(BaseNoGui.getSketchbookFolder(), "tools"); addTools(toolsMenu, sketchbookTools); toolsMenu.addSeparator(); numTools = toolsMenu.getItemCount(); // XXX: DAM: these should probably be implemented using the Tools plugin // API, if possible (i.e. if it supports custom actions, etc.) for (JMenu menu : base.getBoardsCustomMenus()) { toolsMenu.add(menu); } if (serialMenu == null) serialMenu = new JMenu(_("Port")); populatePortMenu(); toolsMenu.add(serialMenu); toolsMenu.addSeparator(); JMenu programmerMenu = new JMenu(_("Programmer")); base.rebuildProgrammerMenu(programmerMenu); toolsMenu.add(programmerMenu); item = new JMenuItem(_("Burn Bootloader")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handleBurnBootloader(); } }); toolsMenu.add(item); toolsMenu.addMenuListener(new StubMenuListener() { public void menuSelected(MenuEvent e) { //System.out.println("Tools menu selected."); populatePortMenu(); for (Component c : toolsMenu.getMenuComponents()) { if ((c instanceof JMenu) && c.isVisible()) { JMenu menu = (JMenu) c; String name = menu.getText(); if (name == null) continue; String basename = name; int index = name.indexOf(':'); if (index > 0) basename = name.substring(0, index); String sel = null; int count = menu.getItemCount(); for (int i = 0; i < count; i++) { JMenuItem item = menu.getItem(i); if (item != null && item.isSelected()) { sel = item.getText(); if (sel != null) break; } } if (sel == null) { if (!name.equals(basename)) menu.setText(basename); } else { if (sel.length() > 50) sel = sel.substring(0, 50) + "..."; String newname = basename + ": \"" + sel + "\""; if (!name.equals(newname)) menu.setText(newname); } } } } }); return toolsMenu; }