java.awt.Menu Java Examples
The following examples show how to use
java.awt.Menu.
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: RemoveHelpMenu.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #2
Source File: RemoveHelpMenu.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #3
Source File: RemoveHelpMenu.java From hottub with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #4
Source File: MyMenuBar.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
/** Eclipse optimizes away the RCN */ @Override @DesireWarning("RCN") public void setHelpMenu(Menu m) { synchronized (getTreeLock()) { if (helpMenu == m) { return; } if (helpMenu != null) { remove(helpMenu); } if (m.getParent() != this) { add(m); } helpMenu = m; if (m != null) { super.setHelpMenu(m); } } }
Example #5
Source File: RemoveHelpMenu.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #6
Source File: RemoveHelpMenu.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #7
Source File: RemoveHelpMenu.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void test3(final MenuBar menuBar) { final Menu helpMenu1 = new Menu("Help Menu1"); final Menu helpMenu2 = new Menu("Help Menu2"); menuBar.setHelpMenu(helpMenu1); checkCurrentMenu(menuBar, helpMenu1); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, true); checkHelpMenu(helpMenu2, false); menuBar.setHelpMenu(helpMenu2); checkCurrentMenu(menuBar, helpMenu2); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, true); menuBar.remove(helpMenu2); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu1, false); checkHelpMenu(helpMenu2, false); }
Example #8
Source File: Utils.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
static private void restoreMenu(final Menu menu) { final int n_menuitems = menu.getItemCount(); for (int i=0; i<n_menuitems; i++) { final MenuItem menu_item = menu.getItem(i); if (menu_item instanceof Menu) { restoreMenu((Menu)menu_item); } menu_item.setEnabled(true); } }
Example #9
Source File: RemoveHelpMenu.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void test2(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.remove(helpMenu); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #10
Source File: RemoveHelpMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void test4(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.setHelpMenu(null); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #11
Source File: RemoveHelpMenu.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void test4(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.setHelpMenu(null); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #12
Source File: Test4520754.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
Example #13
Source File: CMenu.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public final void setEnabled(final boolean b) { super.setEnabled(b); final Menu target = (Menu) getTarget(); final int count = target.getItemCount(); for (int i = 0; i < count; ++i) { MenuItem item = target.getItem(i); MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item); if (p != null) { p.setEnabled(b && item.isEnabled()); } } }
Example #14
Source File: Test4520754.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
Example #15
Source File: DatabaseManager.java From evosql with Apache License 2.0 | 5 votes |
void addMenuItems(Menu f, String[] m) { for (int i = 0; i < m.length; i++) { MenuItem item = new MenuItem(m[i].substring(1)); char c = m[i].charAt(0); if (c != '-') { item.setShortcut(new MenuShortcut(c)); } item.addActionListener(this); f.add(item); } }
Example #16
Source File: GUI.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") private static Menu makesToolsMenu() { Menu toolsMenu = new Menu("Tools"); MenuItem optionsItem = new MenuItem("Options"); toolsMenu.add(optionsItem); optionsItem.addActionListener(e -> IdeOptions.showOptions()); // MenuItem chaseItem = new MenuItem("ED Chaser"); // toolsMenu.add(chaseItem); // chaseItem.addActionListener(x -> Chase.dostuff()); //MenuItem sqlLoaderItem = new MenuItem("SQL Loader"); //toolsMenu.add(sqlLoaderItem); //sqlLoaderItem.addActionListener(x -> SqlLoader.showLoader()); /* MenuItem sqlMapperItem = new MenuItem("SQL Mapper"); toolsMenu.add(sqlMapperItem); sqlMapperItem.addActionListener(x -> SqlMapper.showGuesser()); */ MenuItem sqlCheckItem = new MenuItem("SQL Checker"); toolsMenu.add(sqlCheckItem); sqlCheckItem.addActionListener(x -> new SqlChecker()); MenuItem shredItem = new MenuItem("NR Shredder"); toolsMenu.add(shredItem); shredItem.addActionListener(x -> new NraViewer()); MenuItem easikItem = new MenuItem("EASIK"); toolsMenu.add(easikItem); easikItem.addActionListener(x -> easik.Easik.main(new String[0])); return toolsMenu; }
Example #17
Source File: RemoveHelpMenu.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void test4(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.setHelpMenu(null); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #18
Source File: RemoveHelpMenu.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void test4(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.setHelpMenu(null); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #19
Source File: RemoveHelpMenu.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void test2(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.remove(helpMenu); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #20
Source File: RemoveHelpMenu.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void test4(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.setHelpMenu(null); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #21
Source File: Test4520754.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
Example #22
Source File: ActionEventTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public ActionEventTest() { menuBar = new MenuBar(); Menu menu = new Menu("Menu1"); MenuItem menuItem = new MenuItem("MenuItem"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { System.out.println("actionPerformed"); int md = ae.getModifiers(); int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK; isProgInterruption = true; mainThread.interrupt(); if ((md & expectedMask) != expectedMask) { throw new RuntimeException("Action Event modifiers are not" + " set correctly."); } } }); menu.add(menuItem); menuBar.add(menu); setMenuBar(menuBar); instructions = new TextArea(10, 50); instructions.setText( " This is a manual test\n" + " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" + " Click 'Menu1' Menu from the Menu Bar\n" + " It will show 'MenuItem'\n" + " Left mouse Click the 'MenuItem'\n" + " Test exits automatically after mouse click."); add(instructions); setSize(400, 400); setVisible(true); validate(); }
Example #23
Source File: RemoveHelpMenu.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void test2(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.remove(helpMenu); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #24
Source File: Test4520754.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
Example #25
Source File: RemoveHelpMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void test2(final MenuBar menuBar) { final Menu helpMenu = new Menu("Help Menu"); menuBar.setHelpMenu(helpMenu); checkCurrentMenu(menuBar, helpMenu); checkMenuCount(menuBar, 1); checkHelpMenu(helpMenu, true); menuBar.remove(helpMenu); checkCurrentMenu(menuBar, null); checkMenuCount(menuBar, 0); checkHelpMenu(helpMenu, false); }
Example #26
Source File: Utils.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/**Restore ImageJ's MenuBar*/ static public final void restoreMenuBar() { final MenuBar menu_bar = Menus.getMenuBar(); final int n_menus = menu_bar.getMenuCount(); for (int i=0; i<n_menus;i++) { final Menu menu = menu_bar.getMenu(i); restoreMenu(menu); } //make sure there isn't a null menu bar //WindowManager.getCurrentWindow().setMenuBar(menu_bar); }
Example #27
Source File: Test4520754.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
Example #28
Source File: Utils.java From Scripts with GNU General Public License v3.0 | 5 votes |
/** * Returns the index of the MenuItem labeled by the specified string. * * @param menu * the java.awt.Menu to be parsed * @param label * the java.awt.MenuItem label being searched * @return the index of the java.awt.MenuItem. Returns {@code -1} if no * match is found, {@code null} if menu is not available. */ private Integer getMenuItem(final Menu menu, final String label) { int position = -1; if (menu == null) { return null; } for (int i = 0; i < menu.getItemCount(); i++) { if (menu.getItem(i).getLabel().equals(label)) { position = i; break; } } return position; }
Example #29
Source File: RemoveHelpMenu.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void checkHelpMenu(final Menu menu, final boolean expected) { final boolean actual = menu.toString().contains("isHelpMenu=true"); if (actual != expected) { throw new RuntimeException("Incorrect menu type"); } }
Example #30
Source File: MenuBarSetFont.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static void addMenu() { mb.add(new Menu("w")); frame.validate(); }