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