Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java
38828 views
1
/*
2
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/* @test
25
@bug 8079595
26
@summary Resizing dialog which is JWindow parent makes JVM crash
27
@author Semyon Sadetsky
28
*/
29
30
import javax.swing.*;
31
import java.awt.*;
32
import java.awt.event.ActionEvent;
33
import java.awt.event.ActionListener;
34
import java.awt.event.InputEvent;
35
36
public class ShowChildWhileResizingTest {
37
38
private static Window dialog;
39
private static Timer timer;
40
private static Point point;
41
42
public static void main(String[] args) throws Exception {
43
dialog = new Frame();
44
dialog.add(new JPanel());
45
dialog.setVisible(true);
46
dialog.setBounds(100, 100, 200, 200);
47
SwingUtilities.invokeAndWait(new Runnable() {
48
@Override
49
public void run() {
50
final Window dependentWindow = new JWindow(dialog);
51
JPanel panel = new JPanel();
52
panel.add(new JButton("button"));
53
dependentWindow.add(panel);
54
dependentWindow.setVisible(true);
55
dependentWindow.setBounds(0, 0, 50, 50);
56
timer = new Timer(100, new ActionListener() {
57
@Override
58
public void actionPerformed(ActionEvent e) {
59
dependentWindow
60
.setVisible(!dependentWindow.isVisible());
61
}
62
});
63
timer.start();
64
}
65
66
});
67
68
Robot robot = new Robot();
69
robot.setAutoDelay(5);
70
robot.delay(300);
71
SwingUtilities.invokeAndWait(new Runnable() {
72
@Override
73
public void run() {
74
point = dialog.getLocationOnScreen();
75
}
76
});
77
robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,
78
point.y + 200 - dialog.getInsets().bottom/2);
79
robot.mousePress(InputEvent.BUTTON1_MASK);
80
for(int i = 0; i < 100; i++) {
81
robot.mouseMove(point.x + 200 + i, point.y + 200 + i);
82
}
83
robot.mouseRelease(InputEvent.BUTTON1_MASK);
84
timer.stop();
85
dialog.dispose();
86
System.out.println("ok");
87
}
88
}
89
90