Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java
41153 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
/*
25
* @test
26
* @key headful
27
* @bug 8079595
28
* @summary Resizing dialog which is JWindow parent makes JVM crash
29
* @author Semyon Sadetsky
30
*/
31
32
import javax.swing.*;
33
import java.awt.*;
34
import java.awt.event.ActionEvent;
35
import java.awt.event.ActionListener;
36
import java.awt.event.InputEvent;
37
38
public class ShowChildWhileResizingTest {
39
40
private static Window dialog;
41
private static Timer timer;
42
private static Point point;
43
44
public static void main(String[] args) throws Exception {
45
dialog = new Frame();
46
dialog.add(new JPanel());
47
dialog.setVisible(true);
48
dialog.setBounds(100, 100, 200, 200);
49
SwingUtilities.invokeAndWait(new Runnable() {
50
@Override
51
public void run() {
52
final Window dependentWindow = new JWindow(dialog);
53
JPanel panel = new JPanel();
54
panel.add(new JButton("button"));
55
dependentWindow.add(panel);
56
dependentWindow.setVisible(true);
57
dependentWindow.setBounds(0, 0, 50, 50);
58
timer = new Timer(100, new ActionListener() {
59
@Override
60
public void actionPerformed(ActionEvent e) {
61
dependentWindow
62
.setVisible(!dependentWindow.isVisible());
63
}
64
});
65
timer.start();
66
}
67
68
});
69
70
Robot robot = new Robot();
71
robot.setAutoDelay(5);
72
robot.delay(300);
73
SwingUtilities.invokeAndWait(new Runnable() {
74
@Override
75
public void run() {
76
point = dialog.getLocationOnScreen();
77
}
78
});
79
robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,
80
point.y + 200 - dialog.getInsets().bottom/2);
81
robot.mousePress(InputEvent.BUTTON1_MASK);
82
for(int i = 0; i < 100; i++) {
83
robot.mouseMove(point.x + 200 + i, point.y + 200 + i);
84
}
85
robot.mouseRelease(InputEvent.BUTTON1_MASK);
86
timer.stop();
87
dialog.dispose();
88
System.out.println("ok");
89
}
90
}
91
92