Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/MenuBar/SeparatorsNavigation/SeparatorsNavigation.java
41153 views
1
/*
2
* Copyright (c) 2020, 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.Frame;
25
import java.awt.Menu;
26
import java.awt.MenuBar;
27
import java.awt.MenuItem;
28
import java.awt.Robot;
29
import java.awt.event.ActionEvent;
30
import java.awt.event.ActionListener;
31
import java.awt.event.KeyEvent;
32
33
/*
34
* @test
35
* @bug 6263470
36
* @requires (os.family != "mac")
37
* @key headful
38
* @summary Menu bugs in XAWT
39
* @author Vyacheslav.Baranov: area= menu
40
* @run main SeparatorsNavigation
41
*/
42
43
/**
44
* SeparatorsNavigation.java
45
*
46
* summary: Creates menu bar with menu consisting of two
47
* separators, then tries to navigate it using keyboard.
48
*/
49
50
public class SeparatorsNavigation {
51
static class Listener implements ActionListener {
52
public void actionPerformed(ActionEvent e) {
53
SeparatorsNavigation.pressed = true;
54
}
55
}
56
57
static Frame f;
58
static MenuBar mb;
59
static Menu m1;
60
static Menu m2;
61
static Menu m3;
62
static MenuItem i31;
63
static Listener l = new Listener();
64
static boolean pressed = false;
65
66
public static void main(String args[]) {
67
f = new Frame();
68
mb = new MenuBar();
69
m1 = new Menu("m1");
70
m2 = new Menu("m2");
71
m3 = new Menu("m3");
72
m1.add(new MenuItem("i11"));
73
m2.add(new MenuItem("-"));
74
m2.add(new MenuItem("-"));
75
mb.add(m1);
76
mb.add(m2);
77
mb.add(m3);
78
i31 = new MenuItem("i31");
79
m3.add(i31);
80
i31.addActionListener(l);
81
f.setMenuBar(mb);
82
f.setSize(400, 400);
83
f.setVisible(true);
84
try {
85
Robot r = new Robot();
86
r.delay(1000);
87
r.keyPress(KeyEvent.VK_F10);
88
r.delay(10);
89
r.keyRelease(KeyEvent.VK_F10);
90
r.delay(1000);
91
r.keyPress(KeyEvent.VK_DOWN);
92
r.delay(10);
93
r.keyRelease(KeyEvent.VK_DOWN);
94
r.delay(1000);
95
r.keyPress(KeyEvent.VK_RIGHT);
96
r.delay(10);
97
r.keyRelease(KeyEvent.VK_RIGHT);
98
r.delay(1000);
99
r.keyPress(KeyEvent.VK_RIGHT);
100
r.delay(10);
101
r.keyRelease(KeyEvent.VK_RIGHT);
102
r.delay(1000);
103
r.keyPress(KeyEvent.VK_ENTER);
104
r.delay(10);
105
r.keyRelease(KeyEvent.VK_ENTER);
106
r.delay(10000);
107
} catch (Exception ex) {
108
throw new RuntimeException("Execution interrupted by an " +
109
"exception " + ex.getLocalizedMessage());
110
} finally {
111
if (f != null) {
112
f.setVisible(false);
113
f.dispose();
114
}
115
}
116
if (!pressed) {
117
throw new RuntimeException("Action was not performed, " +
118
"considering test failed.");
119
}
120
}
121
}
122