java.awt.MenuBar Java Examples
The following examples show how to use
java.awt.MenuBar.
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 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 #2
Source File: CMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override long createModel() { CMenuComponent parent = (CMenuComponent) LWCToolkit.targetToPeer(getTarget().getParent()); if (parent instanceof CMenu) { return parent.executeGet(this::nativeCreateSubMenu); } if (parent instanceof CMenuBar) { MenuBar parentContainer = (MenuBar)getTarget().getParent(); boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget(); int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex(); return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu, insertionLocation)); } throw new InternalError("Parent must be CMenu or CMenuBar"); }
Example #3
Source File: RemoveHelpMenu.java From openjdk-jdk8u 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: 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 #5
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 #6
Source File: DatabaseManager.java From evosql with Apache License 2.0 | 6 votes |
void addMenu(MenuBar b, String name, String[] items) { /* It's a very poor design to encapsulate menu creation this way. * Can't customize the menus this way (e.g. shortcut keys, * mnemonics, disabling, etc. */ Menu menu = new Menu(name); if (name.equals("Tools") && !TT_AVAILABLE) { // Terrible place to do this. Forced to due to method design. menu.setEnabled(false); } addMenuItems(menu, items); b.add(menu); }
Example #7
Source File: CMenu.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override long createModel() { CMenuComponent parent = (CMenuComponent) LWCToolkit.targetToPeer(getTarget().getParent()); if (parent instanceof CMenu) { return parent.executeGet(this::nativeCreateSubMenu); } if (parent instanceof CMenuBar) { MenuBar parentContainer = (MenuBar)getTarget().getParent(); boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget(); int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex(); return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu, insertionLocation)); } throw new InternalError("Parent must be CMenu or CMenuBar"); }
Example #8
Source File: CMenu.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override long createModel() { CMenuComponent parent = (CMenuComponent) LWCToolkit.targetToPeer(getTarget().getParent()); if (parent instanceof CMenu) { return parent.executeGet(this::nativeCreateSubMenu); } if (parent instanceof CMenuBar) { MenuBar parentContainer = (MenuBar)getTarget().getParent(); boolean isHelpMenu = parentContainer.getHelpMenu() == getTarget(); int insertionLocation = ((CMenuBar)parent).getNextInsertionIndex(); return parent.executeGet(ptr -> nativeCreateMenu(ptr, isHelpMenu, insertionLocation)); } throw new InternalError("Parent must be CMenu or CMenuBar"); }
Example #9
Source File: XFramePeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #10
Source File: XFramePeer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #11
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 #12
Source File: RemoveHelpMenu.java From jdk8u60 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 #13
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 #14
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 #15
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 #16
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 #17
Source File: XFramePeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #18
Source File: XFramePeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #19
Source File: XFramePeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #20
Source File: RemoveHelpMenu.java From hottub 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: XFramePeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #22
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 #23
Source File: XFramePeer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #24
Source File: RemoveHelpMenu.java From openjdk-jdk9 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 #25
Source File: RemoveHelpMenu.java From jdk8u-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 #26
Source File: XFramePeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void setMenuBar(MenuBar mb) { // state_lock should always be the second after awt_lock XToolkit.awtLock(); try { synchronized(getStateLock()) { if (mb == menubar) return; if (mb == null) { if (menubar != null) { menubarPeer.xSetVisible(false); menubar = null; menubarPeer.dispose(); menubarPeer = null; } } else { menubar = mb; menubarPeer = (XMenuBarPeer) mb.getPeer(); if (menubarPeer != null) { menubarPeer.init((Frame)target); } } } } finally { XToolkit.awtUnlock(); } reshapeMenubarPeer(); }
Example #27
Source File: CMenuBar.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public CMenuBar(MenuBar target) { super(target); }
Example #28
Source File: RemoveHelpMenu.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private static void checkMenuCount(final MenuBar bar, final int expected) { final int actual = bar.getMenuCount(); if (actual != expected) { throw new RuntimeException("Incorrect menus count"); } }
Example #29
Source File: UtilitiesTest.java From netbeans with Apache License 2.0 | 4 votes |
protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException { throw new IllegalStateException("Method not implemented"); }
Example #30
Source File: RemoveHelpMenu.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static MenuBar getMenuBar(final Frame frame) { final MenuBar menuBar = new MenuBar(); frame.setMenuBar(menuBar); return menuBar; }