JDK-6792401 : Windows LAF: ActiveWindowsIcon should not be greedy with fallback icon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-01-11
  • Updated: 2011-01-19
  • Resolved: 2009-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u14 b01Fixed 7Fixed
Related Reports
Duplicate :  
Description
Windows LAF initDefault() contains following code:

            "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")),

It is lazy trying to fetch system icon from the native library but it is greedy creating icon object for fallback.

This is just 2 tiny icons. Their creation do not waste much resources per se. 
But this also cause extra request to open resources.jar file and retrieve couple of entries from it. And this is much more expensive.

Comments
EVALUATION Unfortunately once WindowsLAF replaces the original icons with ActiveValues, there's no reliable way to get the original icons without resolving the lazy values. And we need them as fallback images. So we could keep names of the images as fallback values. Yes, this means some code from Basic is going to be duplicated in WinLAF.
13-01-2009

SUGGESTED FIX diff -r da8e4dad0b0e addon/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java --- a/addon/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Jan 13 01:29:36 2009 +0300 +++ b/addon/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Jan 13 02:03:43 2009 +0300 @@ -1568,9 +1568,9 @@ public class WindowsLookAndFeel extends "Tree.expandedIcon", treeExpandedIcon, "Tree.collapsedIcon", treeCollapsedIcon, "Tree.openIcon", new ActiveWindowsIcon("win.icon.shellIconBPP", "shell32Icon 5", - (Icon)table.get("Tree.openIcon")), + "Tree.openIcon"), "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP", "shell32Icon 4", - (Icon)table.get("Tree.closedIcon")), + "Tree.closedIcon"), "Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] { "ADD", "expand", @@ -2221,14 +2221,14 @@ public class WindowsLookAndFeel extends */ private class ActiveWindowsIcon implements UIDefaults.ActiveValue { private Icon icon; - private Icon fallback; + private String resource; private String nativeImageName; private DesktopProperty desktopProperty; ActiveWindowsIcon(String desktopPropertyName, - String nativeImageName, Icon fallback) { + String nativeImageName, String resource) { this.nativeImageName = nativeImageName; - this.fallback = fallback; + this.resource = resource; if (System.getProperty("os.name").startsWith("Windows ") && System.getProperty("os.version").compareTo("5.1") < 0) { @@ -2250,8 +2250,8 @@ public class WindowsLookAndFeel extends icon = new ImageIconUIResource(image); } } - if (icon == null && fallback != null) { - icon = fallback; + if (icon == null) { + return (Icon)table.get(resource); } return icon; }
12-01-2009