author | simonis |
Fri, 17 Jan 2014 21:54:30 +0100 | |
changeset 22602 | 0d9a07b0d7e9 |
parent 21243 | 1bb93b4654ef |
child 27764 | 4e79ff3e0602 |
permissions | -rw-r--r-- |
21243
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
1 |
/* |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
4 |
* |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
8 |
* |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
13 |
* accompanied this code). |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
14 |
* |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
18 |
* |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
21 |
* questions. |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
22 |
*/ |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
23 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
24 |
/* @test |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
25 |
* @bug 8016551 |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
26 |
* @summary JMenuItem in WindowsLookAndFeel can't paint default icons |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
27 |
* @author Leonid Romanov |
22602
0d9a07b0d7e9
8028537: PPC64: Updated the JDK regression tests to run on AIX
simonis
parents:
21243
diff
changeset
|
28 |
* @run main/othervm bug8016551 |
21243
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
29 |
*/ |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
30 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
31 |
import javax.swing.*; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
32 |
import java.awt.Graphics; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
33 |
import java.awt.Toolkit; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
34 |
import sun.awt.SunToolkit; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
35 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
36 |
public class bug8016551 { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
37 |
private static volatile RuntimeException exception = null; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
38 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
39 |
public static void main(String[] args) throws Exception { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
40 |
try { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
41 |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
42 |
} catch (Exception e) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
43 |
// We intentionally allow the test to run with other l&f |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
44 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
45 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
46 |
SwingUtilities.invokeAndWait(new Runnable() { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
47 |
@Override |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
48 |
public void run() { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
49 |
try { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
50 |
Icon icon = UIManager.getIcon("InternalFrame.closeIcon"); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
51 |
if (icon == null) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
52 |
return; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
53 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
54 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
55 |
JMenuItem item = new TestMenuItem(icon); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
56 |
JFrame f = new JFrame(); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
57 |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
58 |
f.getContentPane().add(item); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
59 |
f.pack(); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
60 |
f.setVisible(true); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
61 |
} catch (ClassCastException e) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
62 |
throw new RuntimeException(e); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
63 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
64 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
65 |
}); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
66 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
67 |
SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit(); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
68 |
tk.realSync(); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
69 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
70 |
if (exception != null) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
71 |
throw exception; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
72 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
73 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
74 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
75 |
static class TestMenuItem extends JMenuItem { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
76 |
TestMenuItem(Icon icon) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
77 |
super(icon); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
78 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
79 |
|
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
80 |
@Override |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
81 |
public void paint(Graphics g) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
82 |
try { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
83 |
super.paint(g); |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
84 |
} catch (RuntimeException e) { |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
85 |
exception = e; |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
86 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
87 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
88 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
89 |
} |
1bb93b4654ef
8016551: JMenuItem in WindowsLookAndFeel can't paint default icons
leonidr
parents:
diff
changeset
|
90 |