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/JFileChooser/8002077/bug8002077.java
38854 views
1
/*
2
* Copyright (c) 2013, 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.Robot;
25
import java.awt.event.KeyEvent;
26
import javax.swing.JFileChooser;
27
import javax.swing.SwingUtilities;
28
import javax.swing.UIManager;
29
import javax.swing.UIManager.LookAndFeelInfo;
30
31
/**
32
* @test
33
* @bug 8002077
34
* @author Alexander Scherbatiy
35
* @summary Possible mnemonic issue on JFileChooser Save button on nimbus L&F
36
* @library ../../regtesthelpers/
37
* @build Util
38
* @run main bug8002077
39
*/
40
public class bug8002077 {
41
42
private static volatile int fileChooserState = JFileChooser.ERROR_OPTION;
43
44
public static void main(String[] args) throws Exception {
45
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
46
if ("Nimbus".equals(info.getName())) {
47
UIManager.setLookAndFeel(info.getClassName());
48
UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
49
UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
50
runTest();
51
break;
52
}
53
}
54
}
55
56
private static void runTest() throws Exception {
57
Robot robot = new Robot();
58
robot.setAutoDelay(50);
59
60
SwingUtilities.invokeLater(() ->
61
fileChooserState = new JFileChooser().showSaveDialog(null));
62
robot.waitForIdle();
63
64
Util.hitMnemonics(robot, KeyEvent.VK_N);
65
robot.waitForIdle();
66
67
Util.hitKeys(robot, KeyEvent.VK_A);
68
robot.waitForIdle();
69
70
Util.hitMnemonics(robot, KeyEvent.VK_S);
71
robot.waitForIdle();
72
73
if (fileChooserState != JFileChooser.APPROVE_OPTION) {
74
// Close the dialog
75
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
76
robot.waitForIdle();
77
78
throw new RuntimeException("Save button is not pressed!");
79
}
80
}
81
}
82
83