Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/java2d/XRSurfaceData/ComponentResizeTest.java
41152 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
import java.awt.Color;
25
import java.awt.FlowLayout;
26
import javax.swing.JButton;
27
import javax.swing.JCheckBox;
28
import javax.swing.JFrame;
29
import javax.swing.SwingUtilities;
30
import java.awt.Component;
31
import javax.swing.JOptionPane;
32
33
/**
34
* @test
35
* @bug 8039345
36
* @author Prasanta Sadhukhan
37
* @run main/manual ComponentResizeTest
38
* @summary Resizes JFrame so that component drawn inside it gets repainted
39
* without leaving any trails
40
*/
41
public class ComponentResizeTest {
42
43
private static JFrame demoFrame;
44
45
public static void testresize() throws Exception {
46
Thread.sleep(5000);
47
for (int i = 0; i < 20; i++) {
48
SwingUtilities.invokeLater(() -> {
49
demoFrame.setSize(demoFrame.getWidth() + 5, demoFrame.getHeight() + 5);
50
});
51
Thread.sleep(1000);
52
}
53
}
54
55
public static void main(String[] args) throws Exception {
56
SwingUtilities.invokeAndWait(() -> {
57
JOptionPane.showMessageDialog(
58
(Component) null,
59
"The test creates a transparent JFrame and resizes the JFrame. Please verify JFrame is transparent and components (like JButton, checkbox) move without leaving any trails",
60
"information", JOptionPane.INFORMATION_MESSAGE);
61
createAndShowGUI();
62
});
63
64
try {
65
testresize();
66
} finally {
67
SwingUtilities.invokeLater(() -> {
68
demoFrame.dispose();
69
});
70
}
71
72
SwingUtilities.invokeAndWait(() -> {
73
int confirm = JOptionPane.showConfirmDialog(
74
(Component) null,
75
"Did the component resize work without leaving any trails?",
76
"alert", JOptionPane.YES_NO_OPTION);
77
if (confirm == JOptionPane.YES_OPTION) {
78
System.out.println("Test passed");
79
} else {
80
System.out.println("Test failed");
81
throw new RuntimeException("Component resize leaves trail");
82
}
83
});
84
}
85
86
private static void createAndShowGUI() {
87
demoFrame = new JFrame();
88
demoFrame.setSize(300, 300);
89
demoFrame.setLayout(new FlowLayout());
90
demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
91
demoFrame.setUndecorated(true);
92
demoFrame.setBackground(new Color(0f, 0, 0, 0.1f));
93
JCheckBox b = new JCheckBox("Whatever");
94
demoFrame.paintAll(null);
95
b.setOpaque(true);
96
demoFrame.add(b);
97
demoFrame.add(new JButton());
98
demoFrame.setVisible(true);
99
}
100
}
101
102