Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Choice/NonFocusablePopupMenuTest/NonFocusablePopupMenuTest.java
41152 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
/*
25
test
26
@bug 6519005
27
@summary regression: Selection the item on the choice don't work properly in vista ultimate.
28
@author Dmitry Cherepanov area=awt.choice
29
@run applet/manual=yesno NonFocusablePopupMenuTest.html
30
*/
31
32
import java.applet.Applet;
33
import java.awt.*;
34
import java.awt.event.*;
35
36
public class NonFocusablePopupMenuTest extends Applet
37
{
38
public void init()
39
{
40
Choice choice = new Choice();
41
choice.add("111");
42
choice.add("222");
43
choice.add("333");
44
choice.add("444");
45
choice.setFocusable(false);
46
47
this.add(choice);
48
49
this.setLayout (new FlowLayout ());
50
51
String[] instructions =
52
{
53
"1) The applet contains a non-focusable choice, ",
54
"2) Click on the choice by mouse, try to change the selection of the choice, ",
55
"3) If it's not possible to change the selection and popup menu is always open ",
56
" even if you click by mouse on any item of the choice, the test failed, ",
57
"4) Otherwise, the test passed. "
58
};
59
Sysout.createDialogWithInstructions( instructions );
60
61
}//End init()
62
63
public void start ()
64
{
65
66
setSize (200,200);
67
setVisible(true);
68
validate();
69
70
}// start()
71
}
72
73
/* Place other classes related to the test after this line */
74
75
76
77
78
79
/****************************************************
80
Standard Test Machinery
81
DO NOT modify anything below -- it's a standard
82
chunk of code whose purpose is to make user
83
interaction uniform, and thereby make it simpler
84
to read and understand someone else's test.
85
****************************************************/
86
87
/**
88
This is part of the standard test machinery.
89
It creates a dialog (with the instructions), and is the interface
90
for sending text messages to the user.
91
To print the instructions, send an array of strings to Sysout.createDialog
92
WithInstructions method. Put one line of instructions per array entry.
93
To display a message for the tester to see, simply call Sysout.println
94
with the string to be displayed.
95
This mimics System.out.println but works within the test harness as well
96
as standalone.
97
*/
98
99
class Sysout
100
{
101
private static TestDialog dialog;
102
103
public static void createDialogWithInstructions( String[] instructions )
104
{
105
dialog = new TestDialog( new Frame(), "Instructions" );
106
dialog.printInstructions( instructions );
107
dialog.setVisible(true);
108
println( "Any messages for the tester will display here." );
109
}
110
111
public static void createDialog( )
112
{
113
dialog = new TestDialog( new Frame(), "Instructions" );
114
String[] defInstr = { "Instructions will appear here. ", "" } ;
115
dialog.printInstructions( defInstr );
116
dialog.setVisible(true);
117
println( "Any messages for the tester will display here." );
118
}
119
120
121
public static void printInstructions( String[] instructions )
122
{
123
dialog.printInstructions( instructions );
124
}
125
126
127
public static void println( String messageIn )
128
{
129
dialog.displayMessage( messageIn );
130
}
131
132
}// Sysout class
133
134
/**
135
This is part of the standard test machinery. It provides a place for the
136
test instructions to be displayed, and a place for interactive messages
137
to the user to be displayed.
138
To have the test instructions displayed, see Sysout.
139
To have a message to the user be displayed, see Sysout.
140
Do not call anything in this dialog directly.
141
*/
142
class TestDialog extends Dialog
143
{
144
145
TextArea instructionsText;
146
TextArea messageText;
147
int maxStringLength = 80;
148
149
//DO NOT call this directly, go through Sysout
150
public TestDialog( Frame frame, String name )
151
{
152
super( frame, name );
153
int scrollBoth = TextArea.SCROLLBARS_BOTH;
154
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
155
add( "North", instructionsText );
156
157
messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
158
add("Center", messageText);
159
160
pack();
161
162
setVisible(true);
163
}// TestDialog()
164
165
//DO NOT call this directly, go through Sysout
166
public void printInstructions( String[] instructions )
167
{
168
//Clear out any current instructions
169
instructionsText.setText( "" );
170
171
//Go down array of instruction strings
172
173
String printStr, remainingStr;
174
for( int i=0; i < instructions.length; i++ )
175
{
176
//chop up each into pieces maxSringLength long
177
remainingStr = instructions[ i ];
178
while( remainingStr.length() > 0 )
179
{
180
//if longer than max then chop off first max chars to print
181
if( remainingStr.length() >= maxStringLength )
182
{
183
//Try to chop on a word boundary
184
int posOfSpace = remainingStr.
185
lastIndexOf( ' ', maxStringLength - 1 );
186
187
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
188
189
printStr = remainingStr.substring( 0, posOfSpace + 1 );
190
remainingStr = remainingStr.substring( posOfSpace + 1 );
191
}
192
//else just print
193
else
194
{
195
printStr = remainingStr;
196
remainingStr = "";
197
}
198
199
instructionsText.append( printStr + "\n" );
200
201
}// while
202
203
}// for
204
205
}//printInstructions()
206
207
//DO NOT call this directly, go through Sysout
208
public void displayMessage( String messageIn )
209
{
210
messageText.append( messageIn + "\n" );
211
System.out.println(messageIn);
212
}
213
214
}// TestDialog class
215
216