Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JInternalFrame/8020708/bug8020708.java
41153 views
1
/*
2
* Copyright (c) 2013, 2018, 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
* @key headful
39
* @bug 8020708 8032568 8194943
40
* @author Alexander Scherbatiy
41
* @summary NLS: mnemonics missing in SwingSet2/JInternalFrame demo
42
* @library ../../regtesthelpers
43
* @build Util
44
* @run main bug8020708
45
*/
46
public class bug8020708 {
47
48
private static final Locale[] SUPPORTED_LOCALES = {
49
Locale.ENGLISH,
50
new Locale("de"),
51
new Locale("es"),
52
new Locale("fr"),
53
new Locale("it"),
54
new Locale("ja"),
55
new Locale("ko"),
56
new Locale("pt", "BR"),
57
new Locale("sv"),
58
new Locale("zh", "CN"),
59
new Locale("zh", "TW")
60
};
61
private static final String[] LOOK_AND_FEELS = {
62
"Nimbus",
63
"Windows",
64
"Motif"
65
};
66
private static JInternalFrame internalFrame;
67
private static JFrame frame;
68
69
public static void main(String[] args) throws Exception {
70
for (Locale locale : SUPPORTED_LOCALES) {
71
for (String laf : LOOK_AND_FEELS) {
72
Locale.setDefault(locale);
73
if (!installLookAndFeel(laf)) {
74
continue;
75
}
76
testInternalFrameMnemonic(locale);
77
}
78
}
79
}
80
81
static void testInternalFrameMnemonic(Locale locale) throws Exception {
82
Robot robot = new Robot();
83
robot.setAutoDelay(250);
84
robot.setAutoWaitForIdle(true);
85
86
SwingUtilities.invokeAndWait(new Runnable() {
87
@Override
88
public void run() {
89
frame = new JFrame("Test");
90
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
91
frame.setUndecorated(true);
92
frame.setLocationRelativeTo(null);
93
frame.setSize(300, 200);
94
95
JDesktopPane desktop = new JDesktopPane();
96
internalFrame = new JInternalFrame("Test");
97
internalFrame.setSize(200, 100);
98
internalFrame.setClosable(true);
99
desktop.add(internalFrame);
100
internalFrame.setVisible(true);
101
internalFrame.setMaximizable(true);
102
103
frame.getContentPane().add(desktop);
104
frame.setVisible(true);
105
}
106
});
107
108
robot.waitForIdle();
109
110
Point clickPoint = Util.getCenterPoint(internalFrame);
111
robot.mouseMove(clickPoint.x, clickPoint.y);
112
robot.mousePress(InputEvent.BUTTON1_MASK);
113
robot.mouseRelease(InputEvent.BUTTON1_MASK);
114
robot.delay(500);
115
116
Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_ESCAPE);
117
robot.delay(500);
118
119
int keyCode = KeyEvent.VK_C;
120
String mnemonic = UIManager
121
.getString("InternalFrameTitlePane.closeButton.mnemonic");
122
try {
123
keyCode = Integer.parseInt(mnemonic);
124
} catch (NumberFormatException e) {
125
}
126
System.out.println("keyCode " + keyCode);
127
Util.hitKeys(robot, keyCode);
128
129
SwingUtilities.invokeAndWait(new Runnable() {
130
@Override
131
public void run() {
132
if (internalFrame.isVisible()) {
133
throw new RuntimeException("Close mnemonic does not work in "+UIManager.getLookAndFeel() + " for locale " + locale);
134
}
135
frame.dispose();
136
}
137
});
138
robot.delay(500);
139
}
140
141
static final boolean installLookAndFeel(String lafName) throws Exception {
142
UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
143
for (UIManager.LookAndFeelInfo info : infos) {
144
if (info.getClassName().contains(lafName)) {
145
UIManager.setLookAndFeel(info.getClassName());
146
return true;
147
}
148
}
149
return false;
150
}
151
}
152
153