Java Code Examples for javax.swing.JPopupMenu#getLocationOnScreen()
The following examples show how to use
javax.swing.JPopupMenu#getLocationOnScreen() .
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: JPopupMenuUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static void dynamicChange(final JPopupMenu popup, boolean usedToBeContained) { if (!popup.isShowing()) { return; } if (isProblemConfig()) { callRefreshLater(popup); return; } refreshPopup(popup); Point p = popup.getLocationOnScreen(); Point newPt = getPopupMenuOrigin(popup, p); boolean willBeContained = willPopupBeContained(popup, newPt); if (usedToBeContained != willBeContained) { popup.setVisible(false); } if (!newPt.equals(p)) { // if (!NO_POPUP_PLACEMENT_HACK) { // popup.setLocation(newPt.x, newPt.y); // } } if (usedToBeContained != willBeContained) { popup.setVisible(true); } }
Example 6
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 7
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 8
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 9
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 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 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 12
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 13
Source File: JPopupMenuUtils.java From netbeans with Apache License 2.0 | 4 votes |
public static void dynamicChangeToSubmenu(JPopupMenu popup, boolean usedToBeContained) { Object invoker = popup.getInvoker(); if (!(invoker instanceof JMenu)) { return; } JMenu menu = (JMenu) invoker; if (!popup.isShowing()) { return; } if (isProblemConfig()) { callRefreshLater2(popup, menu); return; } refreshPopup(popup); Point p = popup.getLocationOnScreen(); Dimension popupSize = popup.getPreferredSize(); Rectangle popupRect = new Rectangle(p, popupSize); Rectangle screenRect = getScreenRect(); boolean willBeContained = isPopupContained(popup); if (!screenRect.contains(popupRect)) { /* * The menu grew off the edge of the screen. */ menu.setPopupMenuVisible(false); menu.setPopupMenuVisible(true); } else if (usedToBeContained != willBeContained) { /* * The menu grew off the edge of the containing window. * Use the setVisible() hack to change the menu from * lightweight to heavyweight. */ popup.setVisible(false); popup.setVisible(true); } }