Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JInternalFrame/8020708/bug8020708.java
38918 views
1
/*
2
* Copyright (c) 2013, 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.Point;
25
import java.awt.Robot;
26
import java.awt.Toolkit;
27
import java.awt.event.InputEvent;
28
import java.awt.event.KeyEvent;
29
import java.util.Locale;
30
import javax.swing.JDesktopPane;
31
import javax.swing.JFrame;
32
import javax.swing.JInternalFrame;
33
import javax.swing.SwingUtilities;
34
import javax.swing.UIManager;
35
36
/**
37
* @test
38
* @bug 8020708
39
* @author Alexander Scherbatiy
40
* @summary NLS: mnemonics missing in SwingSet2/JInternalFrame demo
41
* @library ../../regtesthelpers
42
* @build Util
43
* @run main bug8020708
44
*/
45
public class bug8020708 {
46
47
private static final Locale[] SUPPORTED_LOCALES = {
48
Locale.ENGLISH,
49
new Locale("de"),
50
new Locale("es"),
51
new Locale("fr"),
52
new Locale("it"),
53
new Locale("ja"),
54
new Locale("ko"),
55
new Locale("pt", "BR"),
56
new Locale("sv"),
57
new Locale("zh", "CN"),
58
new Locale("zh", "TW")
59
};
60
private static final String[] LOOK_AND_FEELS = {
61
"Nimbus",
62
"Windows",
63
"Motif"
64
};
65
private static JInternalFrame internalFrame;
66
private static JFrame frame;
67
68
public static void main(String[] args) throws Exception {
69
for (Locale locale : SUPPORTED_LOCALES) {
70
for (String laf : LOOK_AND_FEELS) {
71
Locale.setDefault(locale);
72
if (!installLookAndFeel(laf)) {
73
continue;
74
}
75
testInternalFrameMnemonic();
76
}
77
}
78
}
79
80
static void testInternalFrameMnemonic() throws Exception {
81
Robot robot = new Robot();
82
robot.setAutoDelay(50);
83
84
SwingUtilities.invokeAndWait(new Runnable() {
85
@Override
86
public void run() {
87
frame = new JFrame("Test");
88
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
89
frame.setSize(300, 200);
90
91
JDesktopPane desktop = new JDesktopPane();
92
internalFrame = new JInternalFrame("Test");
93
internalFrame.setSize(200, 100);
94
internalFrame.setClosable(true);
95
desktop.add(internalFrame);
96
internalFrame.setVisible(true);
97
internalFrame.setMaximizable(true);
98
99
frame.getContentPane().add(desktop);
100
frame.setVisible(true);
101
}
102
});
103
104
robot.waitForIdle();
105
106
Point clickPoint = Util.getCenterPoint(internalFrame);
107
robot.mouseMove(clickPoint.x, clickPoint.y);
108
robot.mousePress(InputEvent.BUTTON1_MASK);
109
robot.mouseRelease(InputEvent.BUTTON1_MASK);
110
robot.waitForIdle();
111
112
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
113
robot.waitForIdle();
114
115
Util.hitKeys(robot, KeyEvent.VK_C);
116
robot.waitForIdle();
117
robot.delay(500);
118
119
SwingUtilities.invokeAndWait(new Runnable() {
120
@Override
121
public void run() {
122
if (internalFrame.isVisible()) {
123
throw new RuntimeException("Close mnemonic does not work in "+UIManager.getLookAndFeel());
124
}
125
frame.dispose();
126
}
127
});
128
}
129
130
static final boolean installLookAndFeel(String lafName) throws Exception {
131
UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
132
for (UIManager.LookAndFeelInfo info : infos) {
133
if (info.getClassName().contains(lafName)) {
134
UIManager.setLookAndFeel(info.getClassName());
135
return true;
136
}
137
}
138
return false;
139
}
140
}
141
142