Java Code Examples for javax.swing.JMenu#getPopupMenu()
The following examples show how to use
javax.swing.JMenu#getPopupMenu() .
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: bug8071705.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 2
Source File: bug8071705.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 3
Source File: bug8071705.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 4
Source File: bug8071705.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 5
Source File: MenuEditLayer.java From netbeans with Apache License 2.0 | 5 votes |
void showMenuPopup(final JMenu menu) { getPopupFactory(); // if already created then just make it visible if(hackedPopupFactory.containerMap.containsKey(menu)) { JPanel view = hackedPopupFactory.containerMap.get(menu); view.setVisible(true); } else { if(!isConfigured(menu)) { configureMenu(null, menu); } final JPopupMenu popup = menu.getPopupMenu(); if(!(popup.getUI() instanceof VisualDesignerPopupMenuUI)) { popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI())); } if (menu.isShowing()) { //force popup view creation hackedPopupFactory.getPopup(menu, null, 0, 0); // do later so that the component will definitely be on screen by then SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { popup.show(menu,0,menu.getHeight()); } catch (Exception ex) { ex.printStackTrace(); //ignore anyexceptions caused by showing the popups } } }); } } this.validate(); }
Example 6
Source File: MenuEditLayer.java From netbeans with Apache License 2.0 | 5 votes |
void configureMenu(final JComponent parent, final JMenu menu) { // make sure it will draw it's border so we can have rollovers and selection menu.setBorderPainted(true); //install the wrapper icon if not a toplevel JMenu if(!isTopLevelMenu(menu)) { if(!(menu.getIcon() instanceof WrapperIcon)) { menu.setIcon(new WrapperIcon(menu.getIcon())); } } // configure the maps and popups JPopupMenu popup = menu.getPopupMenu(); menuPopupUIMap.put(menu, popup.getUI()); popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI())); // get all of the components in this menu Component[] subComps = menu.getMenuComponents(); // if this isn't the first time this menu has been opened then the sub components // will have been moved to the popupPanel already, so we will find them there instead. JPanel popupPanel = getPopupFactory().containerMap.get(menu); if(popupPanel != null) { subComps = popupPanel.getComponents(); } RADVisualContainer menuRAD = (RADVisualContainer) formDesigner.getMetaComponent(menu); registerForm(menuRAD,menu); // recurse for sub-menus for(Component c : subComps) { if(c instanceof JMenu) { configureMenu(menu, (JMenu)c); RADComponent rad = formDesigner.getMetaComponent(c); registerForm((RADVisualContainer)rad,(JMenu)c); } else { configureMenuItem(menu, (JComponent) c); } } }
Example 7
Source File: MenuEditLayer.java From netbeans with Apache License 2.0 | 5 votes |
private void unconfigureMenu(final JMenu menu) { if (hackedPopupFactory == null) return; // Issue 145981 // restore the UI menu.getPopupMenu().setUI(menuPopupUIMap.get(menu)); // restore all children JPanel popup = hackedPopupFactory.containerMap.get(menu); if(popup != null) { for(Component c : popup.getComponents()) { if(c instanceof JMenu) { unconfigureMenu((JMenu)c); } else { unconfigureMenuItem((JComponent) c); } } //hide the popup(s) if it's still visible if(menu.getPopupMenu() != null) { menu.getPopupMenu().setVisible(false); } popup.setVisible(false); //layers.remove(popup); } VisualDesignerJPanelPopup pop = hackedPopupFactory.getPopup(menu); if(pop != null) { pop.hide(); } if(popup != null) { popup.setVisible(false); } menu.setPopupMenuVisible(false); hackedPopupFactory.containerMap.remove(menu); }
Example 8
Source File: bug8071705.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 9
Source File: bug8071705.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 10
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 11
Source File: bug8071705.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 12
Source File: bug8071705.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 13
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 14
Source File: bug8071705.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean [] result) { Rectangle screenBounds = setLocation(frame, device); JMenu menu = frame.getJMenuBar().getMenu(0); menu.doClick(); Point location = menu.getLocationOnScreen(); JPopupMenu pm = menu.getPopupMenu(); Dimension pmSize = pm.getSize(); int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY"); int height = location.y + yOffset + pmSize.height + menu.getHeight(); int available = screenBounds.y + screenBounds.height - height; if (available > 0) { Point origin = pm.getLocationOnScreen(); if (origin.y < location.y) { // growing upward, wrong! result[0] = false; } else { // growing downward, ok! result[0] = true; } } else { // there is no space, growing upward would be ok, so we pass result[0] = true; } }
Example 15
Source File: MenuScroller.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 2 votes |
/** * Constructs a <code>MenuScroller</code> that scrolls a menu with the * specified number of items to display in the scrolling region, the * specified scrolling interval, and the specified numbers of items fixed at * the top and bottom of the menu. * * @param menu the menu * @param scrollCount the number of items to display in the scrolling * portion * @param interval the scroll interval, in milliseconds * @param topFixedCount the number of items to fix at the top. May be 0 * @param bottomFixedCount the number of items to fix at the bottom. May be * 0 * @throws IllegalArgumentException if scrollCount or interval is 0 or * negative or if topFixedCount or bottomFixedCount is negative */ public MenuScroller(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) { this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount); }
Example 16
Source File: MenuScroller.java From megamek with GNU General Public License v2.0 | 2 votes |
/** * Constructs a <code>MenuScroller</code> that scrolls a menu with the * specified number of items to display in the scrolling region, the * specified scrolling interval, and the specified numbers of items fixed at * the top and bottom of the menu. * * @param menu the menu * @param scrollCount the number of items to display in the scrolling portion * @param interval the scroll interval, in milliseconds * @param topFixedCount the number of items to fix at the top. May be 0 * @param bottomFixedCount the number of items to fix at the bottom. May be 0 * @throws IllegalArgumentException if scrollCount or interval is 0 or * negative or if topFixedCount or bottomFixedCount is negative */ public MenuScroller(JMenu menu, int scrollCount, int interval, int topFixedCount, int bottomFixedCount) { this(menu.getPopupMenu(), scrollCount, interval, topFixedCount, bottomFixedCount); }