Java Code Examples for java.awt.Frame#setUndecorated()

The following examples show how to use java.awt.Frame#setUndecorated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaximizedNormalBoundsUndecoratedTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
boolean doTest() {
    Dimension beforeMaximizeCalled = new Dimension(300,300);

    frame = new Frame("Test Frame");
    frame.setUndecorated(true);
    frame.setFocusable(true);
    frame.setSize(beforeMaximizeCalled);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.NORMAL);

    Dimension afterMaximizedCalled= frame.getBounds().getSize();

    frame.dispose();

    if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
        return true;
    }
    return false;
}
 
Example 2
Source File: MaximizedNormalBoundsUndecoratedTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
boolean doTest() {
    Dimension beforeMaximizeCalled = new Dimension(300,300);

    frame = new Frame("Test Frame");
    frame.setUndecorated(true);
    frame.setFocusable(true);
    frame.setSize(beforeMaximizeCalled);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.NORMAL);

    Dimension afterMaximizedCalled= frame.getBounds().getSize();

    frame.dispose();

    if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
        return true;
    }
    return false;
}
 
Example 3
Source File: SharedMemoryPixmapsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new instance of SharedMemoryPixmapsTest */
public SharedMemoryPixmapsTest() {
    testFrame = new Frame("SharedMemoryPixmapsTest");
    testFrame.add(new TestComponent());
    testFrame.setUndecorated(true);
    testFrame.setResizable(false);
    testFrame.pack();
    testFrame.setLocationRelativeTo(null);
    testFrame.setVisible(true);
    testFrame.toFront();
}
 
Example 4
Source File: PaintNativeOnUpdate.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 5
Source File: PaintNativeOnUpdate.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 6
Source File: SharedMemoryPixmapsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new instance of SharedMemoryPixmapsTest */
public SharedMemoryPixmapsTest() {
    testFrame = new Frame("SharedMemoryPixmapsTest");
    testFrame.add(new TestComponent());
    testFrame.setUndecorated(true);
    testFrame.setResizable(false);
    testFrame.pack();
    testFrame.setLocationRelativeTo(null);
    testFrame.setVisible(true);
    testFrame.toFront();
}
 
Example 7
Source File: PaintNativeOnUpdate.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 8
Source File: SharedMemoryPixmapsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new instance of SharedMemoryPixmapsTest */
public SharedMemoryPixmapsTest() {
    testFrame = new Frame("SharedMemoryPixmapsTest");
    testFrame.add(new TestComponent());
    testFrame.setUndecorated(true);
    testFrame.setResizable(false);
    testFrame.pack();
    testFrame.setLocationRelativeTo(null);
    testFrame.setVisible(true);
    testFrame.toFront();
}
 
Example 9
Source File: PaintNativeOnUpdate.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Frame frame = new Frame();
    final Component label = new PaintNativeOnUpdate();
    frame.setBackground(Color.RED);
    frame.add(label);
    frame.setSize(300, 300);
    frame.setUndecorated(true);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    sleep();
    label.repaint();// first paint
    sleep();
    label.repaint();// incremental paint
    sleep();

    Robot robot = new Robot();
    robot.setAutoDelay(50);
    Point point = label.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + label.getWidth() / 2,
                                      point.y + label.getHeight() / 2);
    if (!color.equals(Color.GREEN)) {
        System.err.println("Expected color = " + Color.GREEN);
        System.err.println("Actual color = " + color);
        throw new RuntimeException();
    }
    frame.dispose();
}
 
Example 10
Source File: SharedMemoryPixmapsTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a new instance of SharedMemoryPixmapsTest */
public SharedMemoryPixmapsTest() {
    testFrame = new Frame("SharedMemoryPixmapsTest");
    testFrame.add(new TestComponent());
    testFrame.setUndecorated(true);
    testFrame.setResizable(false);
    testFrame.pack();
    testFrame.setLocationRelativeTo(null);
    testFrame.setVisible(true);
    testFrame.toFront();
}
 
Example 11
Source File: MultiScreenInsetsTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
Example 12
Source File: MultiScreenInsetsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
Example 13
Source File: MultiScreenInsetsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
Example 14
Source File: IncorrectDisplayModeExitFullscreen.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) {

        final GraphicsDevice[] devices =
                GraphicsEnvironment.getLocalGraphicsEnvironment()
                                   .getScreenDevices();
        if (devices.length < 2 || devices[0].getDisplayModes().length < 2
                || !devices[0].isFullScreenSupported()
                || !devices[1].isFullScreenSupported()) {
            System.err.println("Testcase is not applicable");
            return;
        }
        final DisplayMode defaultDM = devices[0].getDisplayMode();
        final DisplayMode[] dms = devices[0].getDisplayModes();
        DisplayMode nonDefaultDM = null;

        for (final DisplayMode dm : dms) {
            if (!dm.equals(defaultDM)) {
                nonDefaultDM = dm;
                break;
            }
        }
        if (nonDefaultDM == null) {
            System.err.println("Testcase is not applicable");
            return;
        }

        try {
            robot = new ExtendedRobot();
        }catch(Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException("Unexpected failure");
        }

        final Frame frame = new Frame();
        frame.setBackground(Color.GREEN);
        frame.setUndecorated(true);
        try {
            devices[0].setFullScreenWindow(frame);
            sleep();
            devices[0].setDisplayMode(nonDefaultDM);
            sleep();
            devices[1].setFullScreenWindow(frame);
            sleep();
            if (!defaultDM.equals(devices[0].getDisplayMode())) {
                throw new RuntimeException("DisplayMode is not restored");
            }
        } finally {
            // cleaning up
            devices[0].setFullScreenWindow(null);
            devices[1].setFullScreenWindow(null);
            frame.dispose();
        }
    }
 
Example 15
Source File: IncorrectDisplayModeExitFullscreen.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) {

        final GraphicsDevice[] devices =
                GraphicsEnvironment.getLocalGraphicsEnvironment()
                                   .getScreenDevices();
        if (devices.length < 2 || devices[0].getDisplayModes().length < 2
                || !devices[0].isFullScreenSupported()
                || !devices[1].isFullScreenSupported()) {
            System.err.println("Testcase is not applicable");
            return;
        }
        final DisplayMode defaultDM = devices[0].getDisplayMode();
        final DisplayMode[] dms = devices[0].getDisplayModes();
        DisplayMode nonDefaultDM = null;

        for (final DisplayMode dm : dms) {
            if (!dm.equals(defaultDM)) {
                nonDefaultDM = dm;
                break;
            }
        }
        if (nonDefaultDM == null) {
            System.err.println("Testcase is not applicable");
            return;
        }

        final Frame frame = new Frame();
        frame.setBackground(Color.GREEN);
        frame.setUndecorated(true);
        try {
            devices[0].setFullScreenWindow(frame);
            sleep();
            devices[0].setDisplayMode(nonDefaultDM);
            sleep();
            devices[1].setFullScreenWindow(frame);
            sleep();
            if (!defaultDM.equals(devices[0].getDisplayMode())) {
                throw new RuntimeException("DisplayMode is not restored");
            }
        } finally {
            // cleaning up
            devices[0].setFullScreenWindow(null);
            devices[1].setFullScreenWindow(null);
            frame.dispose();
        }
    }
 
Example 16
Source File: WindowBuilders.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void setupInstance(Frame instance) {
    super.setupInstance(instance);
    
    instance.setUndecorated(undecorated);
    if (image != null) instance.setIconImage(image);
}
 
Example 17
Source File: MultiScreenLocationTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws AWTException
{
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multiscreen test... skipping!");
        return;
    }

    for (int i = 0; i < gds.length; ++i) {
        GraphicsDevice gd = gds[i];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle screen = gc.getBounds();
        Robot robot = new Robot(gd);

        // check Robot.mouseMove()
        robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
        Point mouse = MouseInfo.getPointerInfo().getLocation();
        Point point = screen.getLocation();
        point.translate(mouseOffset.x, mouseOffset.y);
        if (!point.equals(mouse)) {
            throw new RuntimeException(getErrorText("Robot.mouseMove", i));
        }

        // check Robot.getPixelColor()
        Frame frame = new Frame(gc);
        frame.setUndecorated(true);
        frame.setSize(100, 100);
        frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
        frame.setBackground(color);
        frame.setVisible(true);
        robot.waitForIdle();
        Rectangle bounds = frame.getBounds();
        if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
            throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
        }

        // check Robot.createScreenCapture()
        BufferedImage image = robot.createScreenCapture(bounds);
        int rgb = color.getRGB();
        if (image.getRGB(0, 0) != rgb
            || image.getRGB(image.getWidth() - 1, 0) != rgb
            || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
            || image.getRGB(0, image.getHeight() - 1) != rgb) {
                throw new RuntimeException(
                        getErrorText("Robot.createScreenCapture", i));
        }
        frame.dispose();
    }

    System.out.println("Test PASSED!");
}
 
Example 18
Source File: MultiScreenInsetsTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
Example 19
Source File: MultiScreenLocationTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws AWTException
{
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multiscreen test... skipping!");
        return;
    }

    for (int i = 0; i < gds.length; ++i) {
        GraphicsDevice gd = gds[i];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle screen = gc.getBounds();
        Robot robot = new Robot(gd);

        // check Robot.mouseMove()
        robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
        Point mouse = MouseInfo.getPointerInfo().getLocation();
        Point point = screen.getLocation();
        point.translate(mouseOffset.x, mouseOffset.y);
        if (!point.equals(mouse)) {
            throw new RuntimeException(getErrorText("Robot.mouseMove", i));
        }

        // check Robot.getPixelColor()
        Frame frame = new Frame(gc);
        frame.setUndecorated(true);
        frame.setSize(100, 100);
        frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
        frame.setBackground(color);
        frame.setVisible(true);
        robot.waitForIdle();
        Rectangle bounds = frame.getBounds();
        if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
            throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
        }

        // check Robot.createScreenCapture()
        BufferedImage image = robot.createScreenCapture(bounds);
        int rgb = color.getRGB();
        if (image.getRGB(0, 0) != rgb
            || image.getRGB(image.getWidth() - 1, 0) != rgb
            || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
            || image.getRGB(0, image.getHeight() - 1) != rgb) {
                throw new RuntimeException(
                        getErrorText("Robot.createScreenCapture", i));
        }
        frame.dispose();
    }

    System.out.println("Test PASSED!");
}
 
Example 20
Source File: ScreenInsetsTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args)
{
    boolean passed = true;

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice gd : gds) {

        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle gcBounds = gc.getBounds();
        Insets gcInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
        int left = gcInsets.left;
        int right = gcInsets.right;
        int bottom = gcInsets.bottom;
        int top = gcInsets.top;
        if (left < 0 || right < 0 || bottom < 0 || top < 0) {
            throw new RuntimeException("Negative value: " + gcInsets);
        }
        int maxW = gcBounds.width / 3;
        int maxH = gcBounds.height / 3;
        if (left > maxW || right > maxW || bottom > maxH || top > maxH) {
            throw new RuntimeException("Big value: " + gcInsets);
        }

        if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
        {
            // this state is used in the test - sorry
            continue;
        }

        Frame f = new Frame("Test", gc);
        f.setUndecorated(true);
        f.setBounds(gcBounds.x + 100, gcBounds.y + 100, 320, 240);
        f.setVisible(true);
        Util.waitForIdle(null);

        f.setExtendedState(Frame.MAXIMIZED_BOTH);
        Util.waitForIdle(null);

        Rectangle fBounds = f.getBounds();
        // workaround: on Windows maximized windows have negative coordinates
        if (fBounds.x < gcBounds.x)
        {
            fBounds.width -= (gcBounds.x - fBounds.x) * 2; // width is decreased
            fBounds.x = gcBounds.x;
        }
        if (fBounds.y < gcBounds.y)
        {
            fBounds.height -= (gcBounds.y - fBounds.y) * 2; // height is decreased
            fBounds.y = gcBounds.y;
        }
        Insets expected = new Insets(fBounds.y - gcBounds.y,
                                     fBounds.x - gcBounds.x,
                                     gcBounds.y + gcBounds.height - fBounds.y - fBounds.height,
                                     gcBounds.x + gcBounds.width - fBounds.x - fBounds.width);

        if (!expected.equals(gcInsets))
        {
            passed = false;
            System.err.println("Wrong insets for GraphicsConfig: " + gc);
            System.err.println("\tExpected: " + expected);
            System.err.println("\tActual: " + gcInsets);
        }

        f.dispose();
    }

    if (!passed)
    {
        throw new RuntimeException("TEST FAILED: Toolkit.getScreenInsets() returns wrong value for some screens");
    }
}