6792401: Windows LAF: ActiveWindowsIcon should not be greedy with fallback icon
authorpeterz
Wed, 21 Jan 2009 21:30:59 +0300
changeset 1847 ead8e9499c20
parent 1846 4a53d636e2f4
child 1848 6ecbe9158c6e
6792401: Windows LAF: ActiveWindowsIcon should not be greedy with fallback icon Summary: Fallback mechanism changed to use symbolic name instead of icon. Reviewed-by: igor, rupashka
jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Mon Jan 19 20:11:58 2009 +0300
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Wed Jan 21 21:30:59 2009 +0300
@@ -1554,10 +1554,10 @@
             "Tree.selectionBackground", SelectionBackgroundColor,
             "Tree.expandedIcon", treeExpandedIcon,
             "Tree.collapsedIcon", treeCollapsedIcon,
-            "Tree.openIcon",   new ActiveWindowsIcon("win.icon.shellIconBPP", "shell32Icon 5",
-                                                     (Icon)table.get("Tree.openIcon")),
-            "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP", "shell32Icon 4",
-                                                     (Icon)table.get("Tree.closedIcon")),
+            "Tree.openIcon",   new ActiveWindowsIcon("win.icon.shellIconBPP",
+                                   "shell32Icon 5", "icons/TreeOpen.gif"),
+            "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
+                                   "shell32Icon 4", "icons/TreeClosed.gif"),
             "Tree.focusInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
                                     "ADD", "expand",
@@ -2205,21 +2205,21 @@
      */
     private class ActiveWindowsIcon implements UIDefaults.ActiveValue {
         private Icon icon;
-        private Icon fallback;
         private String nativeImageName;
+        private String fallbackName;
         private DesktopProperty desktopProperty;
 
         ActiveWindowsIcon(String desktopPropertyName,
-                          String nativeImageName, Icon fallback) {
+                            String nativeImageName, String fallbackName) {
             this.nativeImageName = nativeImageName;
-            this.fallback = fallback;
+            this.fallbackName = fallbackName;
 
             if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
                     OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) {
                 // This desktop property is needed to trigger reloading the icon.
                 // It is kept in member variable to avoid GC.
                 this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) {
-                    protected void updateUI() {
+                    @Override protected void updateUI() {
                         icon = null;
                         super.updateUI();
                     }
@@ -2227,6 +2227,7 @@
             }
         }
 
+        @Override
         public Object createValue(UIDefaults table) {
             if (icon == null) {
                 Image image = (Image)ShellFolder.get(nativeImageName);
@@ -2234,8 +2235,11 @@
                     icon = new ImageIconUIResource(image);
                 }
             }
-            if (icon == null && fallback != null) {
-                icon = fallback;
+            if (icon == null && fallbackName != null) {
+                UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
+                        SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
+                            BasicLookAndFeel.class, fallbackName);
+                icon = (Icon) fallback.createValue(table);
             }
             return icon;
         }