author | mbaesken |
Fri, 30 Jun 2017 16:32:18 +0200 | |
changeset 47147 | 857d25fae728 |
parent 45348 | 383dbc53e342 |
permissions | -rw-r--r-- |
45348
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
1 |
/* |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
4 |
* |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
8 |
* |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
13 |
* accompanied this code). |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
14 |
* |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
18 |
* |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
21 |
* questions. |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
22 |
*/ |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
23 |
|
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
24 |
/** |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
25 |
* @test |
47147
857d25fae728
8183286: Some java/awt and javax/swing tests miss headful jtreg keyword
mbaesken
parents:
45348
diff
changeset
|
26 |
* @key headful |
45348
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
27 |
* @bug 8179665 |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
28 |
* @summary [Windows] java.awt.IllegalComponentStateException: component must |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
29 |
* be showing on the screen to determine its location |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
30 |
* @run main AlwaysOnTopImeTest |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
31 |
*/ |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
32 |
|
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
33 |
import javax.swing.*; |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
34 |
import java.awt.*; |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
35 |
|
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
36 |
public class AlwaysOnTopImeTest { |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
37 |
|
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
38 |
private static JDialog d; |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
39 |
private static JFrame f; |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
40 |
|
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
41 |
public static void main(String[] args) throws Exception { |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
42 |
SwingUtilities.invokeLater(() -> { |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
43 |
f = new JFrame(); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
44 |
f.setVisible(true); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
45 |
d = new JDialog(f); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
46 |
d.add(new JTextField()); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
47 |
d.pack(); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
48 |
d.setModal(true); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
49 |
f.setAlwaysOnTop(true); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
50 |
d.setVisible(true); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
51 |
f.setAlwaysOnTop(false); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
52 |
}); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
53 |
Robot robot = new Robot(); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
54 |
robot.waitForIdle(); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
55 |
robot.delay(200); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
56 |
SwingUtilities.invokeAndWait(() -> d.setVisible(false)); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
57 |
robot.waitForIdle(); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
58 |
robot.delay(200); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
59 |
SwingUtilities.invokeLater(f::dispose); |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
60 |
} |
383dbc53e342
8179665: [Windows] java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
ssadetsky
parents:
diff
changeset
|
61 |
} |