Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java
38828 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/* @test24@bug 807959525@summary Resizing dialog which is JWindow parent makes JVM crash26@author Semyon Sadetsky27*/2829import javax.swing.*;30import java.awt.*;31import java.awt.event.ActionEvent;32import java.awt.event.ActionListener;33import java.awt.event.InputEvent;3435public class ShowChildWhileResizingTest {3637private static Window dialog;38private static Timer timer;39private static Point point;4041public static void main(String[] args) throws Exception {42dialog = new Frame();43dialog.add(new JPanel());44dialog.setVisible(true);45dialog.setBounds(100, 100, 200, 200);46SwingUtilities.invokeAndWait(new Runnable() {47@Override48public void run() {49final Window dependentWindow = new JWindow(dialog);50JPanel panel = new JPanel();51panel.add(new JButton("button"));52dependentWindow.add(panel);53dependentWindow.setVisible(true);54dependentWindow.setBounds(0, 0, 50, 50);55timer = new Timer(100, new ActionListener() {56@Override57public void actionPerformed(ActionEvent e) {58dependentWindow59.setVisible(!dependentWindow.isVisible());60}61});62timer.start();63}6465});6667Robot robot = new Robot();68robot.setAutoDelay(5);69robot.delay(300);70SwingUtilities.invokeAndWait(new Runnable() {71@Override72public void run() {73point = dialog.getLocationOnScreen();74}75});76robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,77point.y + 200 - dialog.getInsets().bottom/2);78robot.mousePress(InputEvent.BUTTON1_MASK);79for(int i = 0; i < 100; i++) {80robot.mouseMove(point.x + 200 + i, point.y + 200 + i);81}82robot.mouseRelease(InputEvent.BUTTON1_MASK);83timer.stop();84dialog.dispose();85System.out.println("ok");86}87}888990