Path: blob/master/test/jdk/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java
41153 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @key headful26* @bug 807959527* @summary Resizing dialog which is JWindow parent makes JVM crash28* @author Semyon Sadetsky29*/3031import javax.swing.*;32import java.awt.*;33import java.awt.event.ActionEvent;34import java.awt.event.ActionListener;35import java.awt.event.InputEvent;3637public class ShowChildWhileResizingTest {3839private static Window dialog;40private static Timer timer;41private static Point point;4243public static void main(String[] args) throws Exception {44dialog = new Frame();45dialog.add(new JPanel());46dialog.setVisible(true);47dialog.setBounds(100, 100, 200, 200);48SwingUtilities.invokeAndWait(new Runnable() {49@Override50public void run() {51final Window dependentWindow = new JWindow(dialog);52JPanel panel = new JPanel();53panel.add(new JButton("button"));54dependentWindow.add(panel);55dependentWindow.setVisible(true);56dependentWindow.setBounds(0, 0, 50, 50);57timer = new Timer(100, new ActionListener() {58@Override59public void actionPerformed(ActionEvent e) {60dependentWindow61.setVisible(!dependentWindow.isVisible());62}63});64timer.start();65}6667});6869Robot robot = new Robot();70robot.setAutoDelay(5);71robot.delay(300);72SwingUtilities.invokeAndWait(new Runnable() {73@Override74public void run() {75point = dialog.getLocationOnScreen();76}77});78robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,79point.y + 200 - dialog.getInsets().bottom/2);80robot.mousePress(InputEvent.BUTTON1_MASK);81for(int i = 0; i < 100; i++) {82robot.mouseMove(point.x + 200 + i, point.y + 200 + i);83}84robot.mouseRelease(InputEvent.BUTTON1_MASK);85timer.stop();86dialog.dispose();87System.out.println("ok");88}89}909192