Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-aarch32-jdk8u
Path: blob/jdk8u272-b10-aarch32-20201026/jdk/test/java/awt/Component/F10TopToplevel/F10TopToplevel.java
48795 views
1
/*
2
* Copyright (c) 2007, 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
test
25
@bug 6533175
26
@summary Block F10 if closest toplevel to keystroke target is not a Frame.
27
@author yuri nesterenko : area=awt.toplevel
28
@run applet F10TopToplevel.html
29
*/
30
31
32
33
/**
34
* F10TopToplevel.java
35
*
36
* summary: tests if F10 has no effect if focused toplevel if not Frame
37
*/
38
39
import java.applet.Applet;
40
import java.awt.*;
41
import java.awt.event.*;
42
43
44
public class F10TopToplevel extends Applet
45
{
46
//Declare things used in the test, like buttons and labels here
47
Frame frame;
48
Dialog dialog;
49
volatile boolean menuToggled = false;
50
51
public void init()
52
{
53
setLayout (new BorderLayout ());
54
55
}//End init()
56
57
public void start ()
58
{
59
//Get things going. Request focus, set size, et cetera
60
setSize (200,200);
61
setVisible(true);
62
validate();
63
64
65
//What would normally go into main() will probably go here.
66
//Use System.out.println for diagnostic messages that you want
67
//to read after the test is done.
68
MenuBar mb;
69
Menu menu;
70
MenuItem item;
71
frame = new Frame("am below");
72
frame.setMenuBar( (mb=new MenuBar()) );
73
menu = new Menu("nu");
74
menu.add((item = new MenuItem("item")));
75
item.addActionListener( new ActionListener() {
76
public void actionPerformed( ActionEvent ae ) {
77
menuToggled = true;
78
}
79
});
80
mb.add(menu);
81
82
frame.setSize(200,200);
83
frame.setLocation( 400,100 );
84
frame.setVisible( true );
85
86
dialog = new Dialog(frame);
87
dialog.setSize( 100,100 );
88
dialog.setVisible(true);
89
90
Robot robot;
91
try {
92
robot = new Robot();
93
robot.setAutoDelay(5);
94
} catch(AWTException e){
95
throw new RuntimeException("cannot create robot.", e);
96
}
97
robot.waitForIdle();
98
robot.mouseMove(dialog.getLocationOnScreen().x + dialog.getWidth()/2,
99
dialog.getLocationOnScreen().y + dialog.getHeight()/2 );
100
robot.waitForIdle();
101
robot.mousePress(InputEvent.BUTTON1_MASK);
102
robot.mouseRelease(InputEvent.BUTTON1_MASK);
103
robot.waitForIdle();
104
robot.keyPress(KeyEvent.VK_F10);
105
robot.keyRelease(KeyEvent.VK_F10);
106
107
robot.delay(10);
108
robot.keyPress(KeyEvent.VK_ENTER);
109
robot.waitForIdle();
110
robot.keyRelease(KeyEvent.VK_ENTER);
111
112
robot.waitForIdle();
113
114
if(menuToggled) {
115
throw new RuntimeException("Oops! Menu should not open.");
116
}
117
118
}// start()
119
120
}// class F10TopToplevel
121
122