javax.swing.JPopupMenu#getLocationOnScreen ( )源码实例Demo

下面列出了javax.swing.JPopupMenu#getLocationOnScreen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: bug8071705.java
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;
    }
}
 
源代码2 项目: TencentKona-8   文件: bug8071705.java
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;
    }
}
 
源代码3 项目: jdk8u60   文件: bug8071705.java
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;
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: bug8071705.java
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;
    }
}
 
源代码5 项目: netbeans   文件: JPopupMenuUtils.java
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);
        }
    }
 
源代码6 项目: openjdk-jdk8u-backup   文件: bug8071705.java
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;
    }
}
 
源代码7 项目: openjdk-jdk9   文件: bug8071705.java
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;
    }
}
 
源代码8 项目: jdk8u-jdk   文件: bug8071705.java
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;
    }
}
 
源代码9 项目: hottub   文件: bug8071705.java
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;
    }
}
 
源代码10 项目: jdk8u_jdk   文件: bug8071705.java
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;
    }
}
 
源代码11 项目: jdk8u-jdk   文件: bug8071705.java
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;
    }
}
 
源代码12 项目: jdk8u-dev-jdk   文件: bug8071705.java
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;
    }
}
 
源代码13 项目: netbeans   文件: JPopupMenuUtils.java
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);
    }
}