changeset 830:cda097df492f

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
author peterz
date Wed, 21 Jan 2009 21:30:59 +0300
parents b06c29386f63
children cf591ddc3456
files src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Mon Jan 19 20:11:58 2009 +0300
+++ b/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;
         }