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/Component/NativeInLightShow/NativeInLightShow.java
47311 views
1
/*
2
* Copyright (c) 2004, 2014, 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 1.0 04/05/20
26
@bug 4140484
27
@summary Heavyweight components inside invisible lightweight containers still show
28
@author Your Name: [email protected]
29
@run main NativeInLightShow
30
*/
31
32
import java.awt.*;
33
import java.awt.event.*;
34
35
36
// The test verifies that the mixing code correctly handles COMPONENT_SHOWN events
37
// while the top-level container is invisible.
38
39
public class NativeInLightShow
40
{
41
//Declare things used in the test, like buttons and labels here
42
static boolean buttonPressed = false;
43
public static void main(String args[]) throws Exception {
44
Frame f = new Frame("Test");
45
46
Robot robot = null;
47
robot = new Robot();
48
robot.setAutoDelay(50);
49
50
Container c = new Container();
51
c.setLayout(new BorderLayout());
52
Button b = new Button("I'm should be visible!");
53
b.addActionListener(new ActionListener()
54
{
55
public void actionPerformed(ActionEvent e) {
56
System.out.println("Test PASSED");
57
buttonPressed = true;
58
}
59
});
60
c.add(b);
61
62
f.add(c);
63
64
f.pack();
65
66
c.setVisible(false);
67
c.setVisible(true);
68
69
// Wait for a while for COMPONENT_SHOW event to be dispatched
70
robot.waitForIdle();
71
72
f.setVisible(true);
73
74
robot.waitForIdle();
75
76
Point buttonLocation = b.getLocationOnScreen();
77
78
robot.mouseMove(buttonLocation.x + 5, buttonLocation.y + 5);
79
robot.mousePress(InputEvent.BUTTON1_MASK);
80
robot.mouseRelease(InputEvent.BUTTON1_MASK);
81
82
// Wait for a while for ACTION event to be dispatched
83
robot.waitForIdle();
84
robot.delay(100);
85
86
if (!buttonPressed) {
87
System.out.println("Test FAILED");
88
throw new RuntimeException("Button was not pressed");
89
}
90
}
91
92
}
93
94