Search in sources :

Example 1 with OSType

use of sun.awt.OSInfo.OSType in project jdk8u_jdk by JetBrains.

the class UITest method main.

public static void main(String[] args) {
    OSType os = OSInfo.getOSType();
    LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
    switch(os) {
        case WINDOWS:
            // Make sure we don't have GTK.
            if (hasLAF("gtk", lafInfo)) {
                throw new RuntimeException("On windows, but GTK is present");
            }
            // Make sure we don't have Aqua.
            if (hasLAF("mac", lafInfo)) {
                throw new RuntimeException("On windows, but Aqua is present");
            }
            // Make sure we have Windows.
            if (!hasLAF("windows", lafInfo)) {
                throw new RuntimeException("On windows and don't have Windows");
            }
            break;
        case MACOSX:
            // Make sure we don't have GTK.
            if (hasLAF("gtk", lafInfo)) {
                throw new RuntimeException("On mac, but GTK is present");
            }
            // Make sure we don't have Windows.
            if (hasLAF("windows", lafInfo)) {
                throw new RuntimeException("On mac, but Windows is present");
            }
            // Make sure we have Aqua.
            if (!hasLAF("mac", lafInfo)) {
                throw new RuntimeException("On mac and don't have Aqua");
            }
            break;
        default:
            // Make sure we don't have Windows.
            if (hasLAF("windows", lafInfo)) {
                throw new RuntimeException("Not on windows and have Windows");
            }
            // Make sure we don't have Aqua.
            if (hasLAF("mac", lafInfo)) {
                throw new RuntimeException("Not on mac and have Aqua");
            }
            // Make sure we have GTK.
            if (!hasLAF("gtk", lafInfo)) {
                throw new RuntimeException("Not on Windows and Mac and don't have GTK!");
            }
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) OSType(sun.awt.OSInfo.OSType)

Example 2 with OSType

use of sun.awt.OSInfo.OSType in project jdk8u_jdk by JetBrains.

the class bug8024061 method main.

public static void main(String[] args) throws AWTException, InvocationTargetException, InterruptedException {
    OSType type = OSInfo.getOSType();
    if (type != OSType.LINUX && type != OSType.SOLARIS) {
        System.out.println("This test is for Linux and Solaris only... " + "skipping!");
        return;
    }
    final bug8024061[] dnd = { null };
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            dnd[0] = new bug8024061();
        }
    });
    final Robot robot = new Robot();
    robot.setAutoDelay(10);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync();
    JFrame frame = dnd[0].frame;
    Point point = frame.getLocationOnScreen();
    Point here = new Point(point.x + 35, point.y + 45);
    Point there = new Point(point.x + 120, point.y + 45);
    here.x += 25;
    robot.mouseMove(here.x, here.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    while (here.x < there.x) {
        here.x += 20;
        robot.mouseMove(here.x, here.y);
        System.out.println("x = " + here.x);
    }
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    System.out.println("finished");
    try {
        if (lock.await(5, TimeUnit.SECONDS)) {
            if (dragEnterException == null) {
                System.out.println("Test passed.");
            } else {
                System.out.println("Test failed.");
                dragEnterException.printStackTrace();
                throw new RuntimeException(dragEnterException);
            }
        } else {
            System.out.println("Test failed. Timeout reached");
            throw new RuntimeException("Timed out waiting for dragEnter()");
        }
    } finally {
        frame.dispose();
    }
}
Also used : OSType(sun.awt.OSInfo.OSType) SunToolkit(sun.awt.SunToolkit)

Example 3 with OSType

use of sun.awt.OSInfo.OSType in project jdk8u_jdk by JetBrains.

the class bug8046391 method main.

public static void main(String[] args) throws Exception {
    OSType type = OSInfo.getOSType();
    if (type != OSType.WINDOWS) {
        System.out.println("This test is for Windows only... skipping!");
        return;
    }
    SwingUtilities.invokeAndWait(() -> {
        try {
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }
        System.out.println("Creating JFileChooser...");
        JFileChooser fileChooser = new JFileChooser();
        System.out.println("Test passed: chooser = " + fileChooser);
    });
// Test fails if creating JFileChooser hangs
}
Also used : UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) JFileChooser(javax.swing.JFileChooser) OSType(sun.awt.OSInfo.OSType) WindowsLookAndFeel(com.sun.java.swing.plaf.windows.WindowsLookAndFeel)

Aggregations

OSType (sun.awt.OSInfo.OSType)3 WindowsLookAndFeel (com.sun.java.swing.plaf.windows.WindowsLookAndFeel)1 JFileChooser (javax.swing.JFileChooser)1 LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)1 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)1 SunToolkit (sun.awt.SunToolkit)1