/* * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @test @summary setAlwaysOnTop doesn't behave correctly in Linux/Solaris under * certain scenarios * @bug 8036915 * @author Semyon Sadetsky * @run main GetScreenLocationTest */ import java.awt.*; public class GetScreenLocationTest { public static void main(String[] args) throws Exception { Robot robot = new Robot(); Window frame = null; for(int i = 0; i < 100; i++) { if(frame != null) frame.dispose(); frame = new Dialog((Frame)null); frame.setSize(200, 200); frame.setVisible(true); robot.waitForIdle(); robot.delay(200); frame.setLocation(500, 500); robot.waitForIdle(); robot.delay(100); Point location = frame.getLocation(); Dimension size = frame.getSize(); frame.dispose(); if(location.x != 500 || location.y != 500) { throw new RuntimeException("getLocation() returns " + "wrong coordinates " + location); } if(size.width != 200 || size.height != 200) { throw new RuntimeException("getSize() is wrong " + size); } } System.out.println("ok"); } }