Search in sources :

Example 6 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class AlwaysOnTopFieldTest method main.

public static void main(String[] args) {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Window window = new Frame("Window 1");
    window.setSize(200, 200);
    window.setAlwaysOnTop(true);
    window.setVisible(true);
    toolkit.realSync();
    Dialog dialog = new Dialog(window, "Owned dialog 1");
    dialog.setSize(200, 200);
    dialog.setLocation(100, 100);
    dialog.setVisible(true);
    toolkit.realSync();
    try {
        if (!window.isAlwaysOnTop()) {
            throw new RuntimeException("Window has wrong isAlwaysOnTop value");
        }
        if (!dialog.isAlwaysOnTop()) {
            throw new RuntimeException("Dialog has wrong isAlwaysOnTop value");
        }
    } finally {
        window.dispose();
        dialog.dispose();
    }
    window = new Frame("Window 2");
    window.setSize(200, 200);
    window.setVisible(true);
    toolkit.realSync();
    dialog = new Dialog(window, "Owned dialog 2");
    dialog.setSize(200, 200);
    dialog.setLocation(100, 100);
    dialog.setVisible(true);
    toolkit.realSync();
    window.setAlwaysOnTop(true);
    toolkit.realSync();
    try {
        if (!window.isAlwaysOnTop()) {
            throw new RuntimeException("Window has wrong isAlwaysOnTop value");
        }
        if (!dialog.isAlwaysOnTop()) {
            throw new RuntimeException("Dialog has wrong isAlwaysOnTop value");
        }
    } finally {
        window.dispose();
        dialog.dispose();
    }
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) Dialog(java.awt.Dialog) SunToolkit(sun.awt.SunToolkit)

Example 7 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class MultiResolutionToolkitImageTest method testToolkitMultiResolutionImageLoad.

static void testToolkitMultiResolutionImageLoad() throws Exception {
    File imageFile = new File(IMAGE_NAME_1X);
    String fileName = imageFile.getAbsolutePath();
    Image image = Toolkit.getDefaultToolkit().getImage(fileName);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.prepareImage(image, -1, -1, new LoadImageObserver());
    final long time = WAIT_TIME + System.currentTimeMillis();
    while ((!isImageLoaded || !isRVObserverCalled) && System.currentTimeMillis() < time) {
        Thread.sleep(50);
    }
    if (!isImageLoaded) {
        throw new RuntimeException("Image is not loaded!");
    }
    if (!isRVObserverCalled) {
        throw new RuntimeException("Resolution Variant observer is not called!");
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) MultiResolutionToolkitImage(sun.awt.image.MultiResolutionToolkitImage) File(java.io.File)

Example 8 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug8032874 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            createAndShowUI();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            table.getRowSorter().toggleSortOrder(0);
            table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
            table.setRowSelectionInterval(1, 2);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < ROW_COUNT; i++) {
                tableModel.remove(0);
                table.getRowSorter().toggleSortOrder(0);
            }
        }
    });
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 9 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug4908142 method main.

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() {
            tree.requestFocus();
            tree.setSelectionRow(0);
        }
    });
    toolkit.realSync();
    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyPress(KeyEvent.VK_D);
    robot.keyRelease(KeyEvent.VK_D);
    toolkit.realSync();
    String sel = Util.invokeOnEDT(new Callable<String>() {

        @Override
        public String call() throws Exception {
            return tree.getLastSelectedPathComponent().toString();
        }
    });
    if (!"aad".equals(sel)) {
        throw new Error("The selected index should be \"aad\", but not " + sel);
    }
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 10 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug6263446 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    robot = new Robot();
    robot.setAutoDelay(50);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowGUI();
        }
    });
    toolkit.realSync();
    Point point = getClickPoint();
    robot.mouseMove(point.x, point.y);
    toolkit.realSync();
    click(1);
    toolkit.realSync();
    assertEditing(false);
    click(2);
    toolkit.realSync();
    checkSelectedText(null);
    click(3);
    toolkit.realSync();
    checkSelectedText(FIRST);
    click(4);
    toolkit.realSync();
    checkSelectedText(ALL);
    setClickCountToStart(1);
    click(1);
    toolkit.realSync();
    checkSelectedText(null);
    click(2);
    toolkit.realSync();
    checkSelectedText(FIRST);
    click(3);
    toolkit.realSync();
    checkSelectedText(ALL);
    setClickCountToStart(3);
    click(1);
    toolkit.realSync();
    assertEditing(false);
    click(2);
    toolkit.realSync();
    assertEditing(false);
    click(3);
    toolkit.realSync();
    checkSelectedText(null);
    click(4);
    toolkit.realSync();
    checkSelectedText(FIRST);
    click(5);
    toolkit.realSync();
    checkSelectedText(ALL);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            table.editCellAt(0, 0);
        }
    });
    toolkit.realSync();
    assertEditing(true);
    click(2);
    toolkit.realSync();
    checkSelectedText(FIRST);
}
Also used : SunToolkit(sun.awt.SunToolkit)

Aggregations

SunToolkit (sun.awt.SunToolkit)120 Robot (java.awt.Robot)26 Point (java.awt.Point)9 Frame (java.awt.Frame)7 JFrame (javax.swing.JFrame)7 BufferedImage (java.awt.image.BufferedImage)5 Rectangle (java.awt.Rectangle)4 FlowLayout (java.awt.FlowLayout)3 TextField (java.awt.TextField)3 Toolkit (java.awt.Toolkit)3 MouseEvent (java.awt.event.MouseEvent)3 JTableHeader (javax.swing.table.JTableHeader)3 Component (java.awt.Component)2 KeyEvent (java.awt.event.KeyEvent)2 VolatileImage (java.awt.image.VolatileImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URL (java.net.URL)2