GetMousePositionWithPopup.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:jdk8u_jdk 作者:
private static void constructTestUI() {
    frame1 = new Frame();
    frame1.setBounds(100, 100, 100, 100);
    frame1.addMouseMotionListener(new MouseMotionAdapter() {

        private boolean shown = false;

        @Override
        public void mouseMoved(MouseEvent e) {
            if (shown) {
                return;
            }

            shown = true;

            frame2 = new Frame();
            frame2.setBounds(120, 120, 120, 120);
            frame2.setVisible(true);

            Point positionInFrame2 = frame2.getMousePosition();
            if (positionInFrame2.x != 30 || positionInFrame2.y != 30) {
                throw new RuntimeException("Wrong position reported. Should be [30, 30] but was [" +
                        positionInFrame2.x + ", " + positionInFrame2.y + "]");
            }

            Point positionInFrame1 = frame1.getMousePosition();
            if (positionInFrame1 != null) {
                throw new RuntimeException("Wrong position reported. Should be null");
            }

        }
    });
    frame1.setVisible(true);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号