author | serb |
Tue, 01 Oct 2013 04:29:50 +0400 | |
changeset 20435 | 543c1c7dd21a |
permissions | -rw-r--r-- |
20435
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
1 |
/* |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
4 |
* |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
8 |
* |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
14 |
* |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
18 |
* |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
21 |
* questions. |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
22 |
*/ |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
23 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
24 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
25 |
import java.applet.Applet; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
26 |
import java.awt.BorderLayout; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
27 |
import java.awt.Dimension; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
28 |
import java.awt.FlowLayout; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
29 |
import java.awt.Panel; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
30 |
import java.awt.TextArea; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
31 |
import java.awt.TextField; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
32 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
33 |
public final class SelectionVisible extends Applet { |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
34 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
35 |
TextField tf; |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
36 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
37 |
@Override |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
38 |
public void init() { |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
39 |
tf = new TextField(20); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
40 |
tf.setText("0123456789"); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
41 |
tf.select(0, 6); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
42 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
43 |
final TextArea ta = new TextArea("INSTRUCTIONS:\n" |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
44 |
+ "The text 012345 should be selected in the TextField.\n" |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
45 |
+ "If this is what you observe, then the test passes.\n" |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
46 |
+ "Otherwise, the test fails.", 40, 5, |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
47 |
TextArea.SCROLLBARS_NONE); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
48 |
ta.setEditable(false); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
49 |
ta.setPreferredSize(new Dimension(300, 70)); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
50 |
final Panel panel = new Panel(); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
51 |
panel.setLayout(new FlowLayout()); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
52 |
panel.add(tf); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
53 |
setLayout(new BorderLayout()); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
54 |
add(ta, BorderLayout.CENTER); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
55 |
add(panel, BorderLayout.PAGE_END); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
56 |
} |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
57 |
|
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
58 |
@Override |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
59 |
public void start() { |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
60 |
setVisible(true); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
61 |
tf.requestFocus(); |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
62 |
} |
543c1c7dd21a
7150100: [macosx] "0123456789" is selected in the TextField
serb
parents:
diff
changeset
|
63 |
} |