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.
|
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;
}
|