author | rupashka |
Fri, 14 Aug 2009 13:18:10 +0400 | |
changeset 3732 | a4009b9b2f65 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
3732
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
1 |
/* |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
2 |
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
4 |
* |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
8 |
* |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
13 |
* accompanied this code). |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
14 |
* |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
18 |
* |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
21 |
* have any questions. |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
22 |
*/ |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
23 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
24 |
/* @test |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
25 |
@bug 6824600 |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
26 |
@summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style) |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
27 |
@author Pavel Porvatov |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
28 |
@run main Test6824600 |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
29 |
*/ |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
30 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
31 |
import com.sun.java.swing.plaf.windows.DesktopProperty; |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
32 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
33 |
import java.awt.*; |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
34 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
35 |
public class Test6824600 { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
36 |
public static void main(String[] args) throws Exception { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
37 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
38 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
39 |
HackedDesktopProperty desktopProperty = new HackedDesktopProperty("Button.background", null); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
40 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
41 |
// Register listener in toolkit |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
42 |
desktopProperty.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
43 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
44 |
int length = toolkit.getPropertyChangeListeners().length; |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
45 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
46 |
// Make several invocations |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
47 |
desktopProperty.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
48 |
desktopProperty.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
49 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
50 |
desktopProperty.invalidate(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
51 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
52 |
desktopProperty.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
53 |
desktopProperty.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
54 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
55 |
if (length != toolkit.getPropertyChangeListeners().length) { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
56 |
throw new RuntimeException("New listeners were added into Toolkit"); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
57 |
} |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
58 |
} |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
59 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
60 |
public static class HackedDesktopProperty extends DesktopProperty { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
61 |
public HackedDesktopProperty(String key, Object fallback) { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
62 |
super(key, fallback); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
63 |
} |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
64 |
|
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
65 |
// Publish the method |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
66 |
public Object getValueFromDesktop() { |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
67 |
return super.getValueFromDesktop(); |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
68 |
} |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
69 |
} |
a4009b9b2f65
6824600: OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
rupashka
parents:
diff
changeset
|
70 |
} |