当前位置: 首页>>代码示例>>Java>>正文


Java SunToolkit.realSync方法代码示例

本文整理汇总了Java中sun.awt.SunToolkit.realSync方法的典型用法代码示例。如果您正苦于以下问题:Java SunToolkit.realSync方法的具体用法?Java SunToolkit.realSync怎么用?Java SunToolkit.realSync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.awt.SunToolkit的用法示例。


在下文中一共展示了SunToolkit.realSync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    Point point = getRowPointToClick(1);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    toolkit.realSync();

    Boolean result = (Boolean)tree.getCellEditor().getCellEditorValue();
    if (!result) {
        throw new RuntimeException("Test Failed!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:bug8023474.java

示例2: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowUI();
        }
    });

    toolkit.realSync();
    clickCell(robot, 1, 1);
    Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
            KeyEvent.VK_BACK_SPACE);

    toolkit.realSync();
    clickColumnHeader(robot, 1);

    toolkit.realSync();
    clickColumnHeader(robot, 1);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:bug7055065.java

示例3: testDispose

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public void testDispose() throws InvocationTargetException,
        InterruptedException {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("Test");

            textArea = new TextArea("editable textArea");
            textArea.setEditable(true);
            // textArea.setEditable(false); // this testcase passes if textArea is non-editable

            frame.setLayout(new FlowLayout());
            frame.add(textArea);

            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
    toolkit.realSync();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:TestDispose.java

示例4: test

import sun.awt.SunToolkit; //导入方法依赖的package包/类
private void test() throws Exception {
    Robot robot = new Robot();
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());

        SwingUtilities.invokeAndWait(this);
        toolkit.realSync(); // after creation
        Thread.sleep(1000);

        Point point = this.bar.getLocation();
        SwingUtilities.convertPointToScreen(point, this.bar);
        point.x += this.bar.getWidth() >> 2;
        point.y += this.bar.getHeight() >> 1;
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        toolkit.realSync(); // before validation
        Thread.sleep(1000);
        SwingUtilities.invokeAndWait(this);

        if (this.bar != null) {
            this.bar = null; // allows to reuse the instance
            if (AUTO) { // error reporting only for automatic testing
                throw new Error("TEST FAILED");
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:Test7163696.java

示例5: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point movePoint = getButtonPoint();
        robot.mouseMove(movePoint.x, movePoint.y);
        toolkit.realSync();

        long timeout = System.currentTimeMillis() + 9000;
        while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
            try {Thread.sleep(500);} catch (Exception e) {}
        }

        checkToolTip();
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:bug4846413.java

示例6: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, null, null, null);
            pane.setWantsInput(true);

            JDialog dialog = pane.createDialog(null, "My Dialog");
            dialog.setVisible(true);

            Object result = pane.getValue();

            if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
                throw new RuntimeException("Invalid result: " + result);
            }

            System.out.println("Test bug7138665 passed");
        }
    });

    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    toolkit.realSync();

    Robot robot = new Robot();

    robot.setAutoDelay(100);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);

    toolkit.realSync();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:bug7138665.java

示例7: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(20);

    final JFrame frame = new JFrame();
    frame.setUndecorated(true);

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JTableHeader th = new JTableHeader();
            th.setColumnModel(new JTable(20, 5).getColumnModel());

            th.setUI(new MyTableHeaderUI());

            frame.add(th);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    Point point = frame.getLocationOnScreen();
    int shift = 10;
    int x = point.x;
    int y = point.y + frame.getHeight()/2;
    for(int i = -shift; i < frame.getWidth() + 2*shift; i++) {
        robot.mouseMove(x++, y);
    }
    toolkit.realSync();
    // 9 is a magic test number
    if (MyTableHeaderUI.getTestValue() != 9) {
        throw new RuntimeException("Unexpected test number "
                + MyTableHeaderUI.getTestValue());
    }
    System.out.println("ok");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:bug6889007.java

示例8: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Test7024235 test = new Test7024235();
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());

        test.test();
        toolkit.realSync();
        Thread.sleep(1000);
        test.test();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test7024235.java

示例9: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(500);


        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point clickPoint = getButtonClickPoint();
        robot.mouseMove(clickPoint.x, clickPoint.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        clickPoint = getMenuClickPoint();
        robot.mouseMove(clickPoint.x, clickPoint.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (RO1.itsValue <= RO2.itsValue) {
            throw new RuntimeException("Offset if the second icon is invalid.");
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:bug6209975.java

示例10: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            createGui();
        }
    });

    toolkit.realSync();

    // Get screen insets
    screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
    if (screenInsets.bottom == 0) {
        // This test is only for configurations with taskbar on the bottom
        return;
    }

    System.setSecurityManager(new SecurityManager(){

        private String allowsAlwaysOnTopPermission = SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();

        @Override
        public void checkPermission(Permission perm) {
            if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
                throw new SecurityException();
            }
        }

    });

    // Show popup as if from an applet
    // The popup shouldn't overlap the task bar. It should be shifted up.
    checkPopup();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:bug6694823.java

示例11: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    EventQueue.invokeAndWait(() -> {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
        comboBox.setEditable(true);
        comboBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if ("comboBoxEdited".equals(e.getActionCommand())) {
                    isComboBoxEdited = true;
                }
            }
        });
        frame.add(comboBox);
        frame.pack();
        frame.setVisible(true);
        comboBox.requestFocusInWindow();
    });

    toolkit.realSync();

    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    toolkit.realSync();

    if(!isComboBoxEdited){
        throw new RuntimeException("ComboBoxEdited event is not fired!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:bug8057893.java

示例12: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("Test");
            TextArea textArea = new TextArea("Non-editable textArea");
            textArea.setEditable(false);
            frame.setLayout(new FlowLayout());
            frame.add(textArea);
            frame.pack();
            frame.setVisible(true);

            try {
                Class XTextAreaPeerClzz  = textArea.getPeer().getClass();
                System.out.println(XTextAreaPeerClzz.getName());
                if (!XTextAreaPeerClzz.getName().equals("sun.awt.X11.XTextAreaPeer")) {
                    fastreturn = true;
                    return;
                }

                Field jtextField = XTextAreaPeerClzz.getDeclaredField("jtext");
                jtextField.setAccessible(true);
                JTextArea jtext = (JTextArea)jtextField.get(textArea.getPeer());
                caret = (DefaultCaret) jtext.getCaret();

                textArea.requestFocusInWindow();
            } catch (NoSuchFieldException | SecurityException
                     | IllegalArgumentException | IllegalAccessException e) {
                /* These exceptions mean the implementation of XTextAreaPeer is
                 * changed, this testcase is not valid any more, fix it or remove.
                 */
                frame.dispose();
                throw new RuntimeException("This testcase is not valid any more!");
            }
        }
    });
    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try{
                if (fastreturn) {
                    return;
                }
                boolean passed = caret.isActive();
                System.out.println("is caret visible : " + passed);

                if (!passed) {
                    throw new RuntimeException("The test for bug 71297422 failed");
                }
            } finally {
                frame.dispose();
            }
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:bug7129742.java

示例13: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            txtField.requestFocus();
        }
    });

    toolkit.realSync();

    if (!focusGained) {
        throw new RuntimeException("Couldn't gain focus for text field");
    }

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            tab.addChangeListener((ChangeListener) listener);
            txtField.removeFocusListener((FocusListener) listener);
        }
    });

    toolkit.realSync();

    if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
    } else {
        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
    }

    toolkit.realSync();

    if (!stateChanged || tab.getSelectedIndex() != 1) {
        throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:50,代码来源:bug4624207.java

示例14: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point point = getButtonCenter();
        robot.mouseMove(point.x, point.y);
        toolkit.realSync();

        checkButtonsSize();

    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:bug4247996.java

示例15: main

import sun.awt.SunToolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String systemLAF = UIManager.getSystemLookAndFeelClassName();
    // the test is not applicable to Motif L&F
    if(systemLAF.endsWith("MotifLookAndFeel")){
        return;
    }

    UIManager.setLookAndFeel(systemLAF);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(10);

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowUI();
        }
    });
    toolkit.realSync();

    // test mouse press
    Point point = Util.getCenterPoint(menu);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();

    point = Util.getCenterPoint(menuItem);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();

    if (!isMenuItemShowing()) {
        throw new RuntimeException("Popup is unexpectedly closed");
    }

    // test mouse drag
    point = Util.getCenterPoint(menu);
    robot.mouseMove(point.x, point.y);
    Point menuLocation = Util.invokeOnEDT(new Callable<Point>() {

        @Override
        public Point call() throws Exception {
            return menu.getLocationOnScreen();
        }
    });

    Point itemLocation = Util.invokeOnEDT(new Callable<Point>() {

        @Override
        public Point call() throws Exception {
            return menuItem.getLocationOnScreen();
        }
    });

    int x0 = menuLocation.x + 10;
    int y0 = menuLocation.y + 10;
    int x1 = itemLocation.x + 10;
    int y1 = itemLocation.y + 10;

    // close menu
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();

    robot.mousePress(InputEvent.BUTTON1_MASK);
    Util.glide(robot, x0, y0, x1, y1);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();

    if (!isMenuItemShowing()) {
        throw new RuntimeException("Popup is unexpectedly closed");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:76,代码来源:bug4654927.java


注:本文中的sun.awt.SunToolkit.realSync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。