author | serb |
Wed, 19 Mar 2014 16:13:59 +0400 | |
changeset 23675 | 7908c1a34e3a |
child 27763 | 1fba965925e8 |
permissions | -rw-r--r-- |
23675
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
1 |
/* |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
4 |
* |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
8 |
* |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
14 |
* |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
18 |
* |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
21 |
* questions. |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
22 |
*/ |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
23 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
24 |
import sun.awt.SunToolkit; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
25 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
26 |
import java.awt.Frame; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
27 |
import java.awt.HeadlessException; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
28 |
import java.awt.List; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
29 |
import java.awt.Toolkit; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
30 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
31 |
/** |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
32 |
* @test |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
33 |
* @summary rdar://problem/2303044 List selection not set when peer is created |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
34 |
* @summary com.apple.junit.java.awt.List; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
35 |
* @run main R2303044ListSelection |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
36 |
*/ |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
37 |
public final class R2303044ListSelection { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
38 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
39 |
public static final String ITEM_NAME = "myItem"; |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
40 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
41 |
public static void main(final String[] args) throws HeadlessException { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
42 |
final Frame frame = new Frame("Test Frame"); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
43 |
final List list = new List(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
44 |
frame.setSize(300, 200); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
45 |
list.add(ITEM_NAME); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
46 |
list.select(0); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
47 |
frame.add(list); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
48 |
frame.validate(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
49 |
frame.setVisible(true); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
50 |
sleep(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
51 |
if (!ITEM_NAME.equals(list.getSelectedItem())) { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
52 |
throw new RuntimeException("List item not selected item."); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
53 |
} |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
54 |
list.removeAll(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
55 |
frame.dispose(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
56 |
} |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
57 |
|
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
58 |
private static void sleep() { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
59 |
try { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
60 |
((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
61 |
Thread.sleep(1000); |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
62 |
} catch (final InterruptedException ignored) { |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
63 |
} |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
64 |
} |
7908c1a34e3a
7124255: [macosx] java.awt.List: method select(int) doesn't work before be visible
serb
parents:
diff
changeset
|
65 |
} |