Java Code Examples for java.awt.Window#setSize()

The following examples show how to use java.awt.Window#setSize() . 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: BackgroundIsNotUpdated.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    window.requestFocus();
    final ExtendedRobot robot = new ExtendedRobot();
    robot.setAutoDelay(200);
    robot.waitForIdle(1000);
    window.setBackground(Color.GREEN);
    robot.waitForIdle(1000);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
Example 2
Source File: BackgroundIsNotUpdated.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    sleep();
    window.setBackground(Color.GREEN);
    sleep();
    final Robot robot = new Robot();
    robot.setAutoDelay(200);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
Example 3
Source File: Show.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public static void pack
        (Window
                window) {
    Dimension dim = window.getPreferredSize();
    int prefw = dim.width;
    int w = window.getWidth();
    if (w < prefw) {
        w = prefw;
    }
    int prefh = dim.height;
    int h = window.getHeight();
    if (h < prefh) {
        h = prefh;
    }
    window.setSize(w, h);
}
 
Example 4
Source File: BackgroundIsNotUpdated.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    sleep();
    window.setBackground(Color.GREEN);
    sleep();
    final Robot robot = new Robot();
    robot.setAutoDelay(200);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
Example 5
Source File: BackgroundIsNotUpdated.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    sleep();
    window.setBackground(Color.GREEN);
    sleep();
    final Robot robot = new Robot();
    robot.setAutoDelay(200);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
Example 6
Source File: Session.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
private void setSizeChecked(Window window, int width, int height)
{
    Dimension screenSize = getScreenSize();
    width = Math.min(width, screenSize.width);
    height = Math.min(height, screenSize.height);
    window.setSize(width, height);
    window.validate();
}
 
Example 7
Source File: PageSetupPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void rebuild(PrintService service, PrintRequestAttributeSet set) {
    removeAll();
    mService = service;
    createPrinterCombo();
    rebuildSelf(set);
    revalidate();
    Window window = WindowUtils.getWindowForComponent(this);
    window.setSize(window.getPreferredSize());
    WindowUtils.forceOnScreen(window);
}
 
Example 8
Source File: LocationByPlatformTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        Window window = new Window(null);
        window.setSize(100, 100);
        window.setLocationByPlatform(true);

        if (!window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not set");
        }

        window.setLocation(10, 10);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setBounds(20, 20, 50, 50);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setVisible(false);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.setLocationByPlatform(true);
        window.setVisible(true);

        if (window.isLocationByPlatform()) {
            throw new RuntimeException("Location by platform is not cleared");
        }

        window.dispose();
    }
 
Example 9
Source File: TreeLockDeadlock.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 10
Source File: TreeLockDeadlock.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 11
Source File: SyncAlwaysOnTopFieldTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static Window createWindow(Window parent) {
    Window window = new Window(parent);
    window.setSize(200, 200);
    window.setVisible(true);
    return window;
}
 
Example 12
Source File: WindowOwnedByEmbeddedFrameTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    try {
        Robot robot = Util.createRobot();
        robot.setAutoDelay(50);

        embeddedFrame = createEmbeddedFrame();

        textField = new TextField("");

        window = new Window(embeddedFrame);
        window.setSize(200, 200);
        window.setLocationRelativeTo(null);
        window.add(textField);
        window.setVisible(true);

        Util.waitForIdle(robot);

        Util.clickOnComp(textField, robot);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_S);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        if ("".equals(textField.getText())) {
            throw new RuntimeException("Keyboard input in text field isn't possible");
        }
    } finally {
        if (embeddedFrame != null) {
            embeddedFrame.dispose();
        }
        if (window != null) {
            window.dispose();
        }
    }
}
 
Example 13
Source File: TreeLockDeadlock.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 14
Source File: TreeLockDeadlock.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 15
Source File: TreeLockDeadlock.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 16
Source File: FullScreenInsets.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
Example 17
Source File: SyncAlwaysOnTopFieldTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static Window createWindow(Window parent) {
    Window window = new Window(parent);
    window.setSize(200, 200);
    window.setVisible(true);
    return window;
}
 
Example 18
Source File: TreeLockDeadlock.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Window window = new TreeLockDeadlock();
    window.setSize(300, 300);
    test(window);
}
 
Example 19
Source File: FullScreenInsets.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(final String[] args) {
    final GraphicsEnvironment ge = GraphicsEnvironment
            .getLocalGraphicsEnvironment();
    final GraphicsDevice[] devices = ge.getScreenDevices();

    final Window wGreen = new Frame();
    wGreen.setBackground(Color.GREEN);
    wGreen.setSize(300, 300);
    wGreen.setVisible(true);
    sleep();
    final Insets iGreen = wGreen.getInsets();
    final Dimension sGreen = wGreen.getSize();

    final Window wRed = new Frame();
    wRed.setBackground(Color.RED);
    wRed.setSize(300, 300);
    wRed.setVisible(true);
    sleep();
    final Insets iRed = wGreen.getInsets();
    final Dimension sRed = wGreen.getSize();

    for (final GraphicsDevice device : devices) {
        if (!device.isFullScreenSupported()) {
            continue;
        }
        device.setFullScreenWindow(wGreen);
        sleep();
        testWindowBounds(device.getDisplayMode(), wGreen);
        testColor(wGreen, Color.GREEN);

        device.setFullScreenWindow(wRed);
        sleep();
        testWindowBounds(device.getDisplayMode(), wRed);
        testColor(wRed, Color.RED);

        device.setFullScreenWindow(null);
        sleep();
        testInsets(wGreen.getInsets(), iGreen);
        testInsets(wRed.getInsets(), iRed);
        testSize(wGreen.getSize(), sGreen);
        testSize(wRed.getSize(), sRed);
    }
    wGreen.dispose();
    wRed.dispose();
    if (!passed) {
        throw new RuntimeException("Test failed");
    }
}
 
Example 20
Source File: WindowOwnedByEmbeddedFrameTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    try {
        Robot robot = Util.createRobot();
        robot.setAutoDelay(50);

        embeddedFrame = createEmbeddedFrame();

        textField = new TextField("");

        window = new Window(embeddedFrame);
        window.setSize(200, 200);
        window.setLocationRelativeTo(null);
        window.add(textField);
        window.setVisible(true);

        Util.waitForIdle(robot);

        Util.clickOnComp(textField, robot);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_S);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        if ("".equals(textField.getText())) {
            throw new RuntimeException("Keyboard input in text field isn't possible");
        }
    } finally {
        if (embeddedFrame != null) {
            embeddedFrame.dispose();
        }
        if (window != null) {
            window.dispose();
        }
    }
}