8153287: [PIT] [hidpi] java/awt/image/multiresolution/MultiresolutionIconTest failed (GTK+ and Nimbus L&F)
authoralexsch
Wed, 31 Aug 2016 12:49:03 +0300
changeset 40987 eb13c2ec3f9a
parent 40986 6aac489a48d2
child 40988 cc334ef95225
8153287: [PIT] [hidpi] java/awt/image/multiresolution/MultiresolutionIconTest failed (GTK+ and Nimbus L&F) Reviewed-by: serb, ssadetsky
jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Wed Aug 31 11:13:53 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Wed Aug 31 12:49:03 2016 +0300
@@ -391,21 +391,8 @@
     }
 
     private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) {
-        ButtonModel model = b.getModel();
-        Icon icon = null;
-        if (model.isSelected()) {
-            icon = getIcon(b, b.getRolloverSelectedIcon(), null,
-                    SynthConstants.MOUSE_OVER | SynthConstants.SELECTED);
-            if (icon == null) {
-                icon = getIcon(b, b.getSelectedIcon(), null,
-                        SynthConstants.SELECTED);
-            }
-        }
-        if (icon == null) {
-            icon = getIcon(b, b.getRolloverIcon(), defaultIcon,
-                    SynthConstants.MOUSE_OVER);
-        }
-        return icon;
+        return getSpecificIcon(b, b.getRolloverSelectedIcon(), b.getRolloverIcon(),
+                               defaultIcon, SynthConstants.MOUSE_OVER);
     }
 
     private Icon getPressedIcon(AbstractButton b, Icon defaultIcon) {
@@ -414,21 +401,44 @@
     }
 
     private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) {
-        ButtonModel model = b.getModel();
+        return getSpecificIcon(b, b.getDisabledSelectedIcon(), b.getDisabledIcon(),
+                               defaultIcon, SynthConstants.DISABLED);
+    }
+
+    private Icon getSpecificIcon(AbstractButton b, Icon specificSelectedIcon,
+                                 Icon specificIcon, Icon defaultIcon,
+                                 int state) {
+        boolean selected = b.getModel().isSelected();
         Icon icon = null;
-        if (model.isSelected()) {
-            icon = getIcon(b, b.getDisabledSelectedIcon(), null,
-                    SynthConstants.DISABLED | SynthConstants.SELECTED);
+
+        if (selected) {
+            icon = specificSelectedIcon;
             if (icon == null) {
-                icon = getIcon(b, b.getSelectedIcon(), null,
-                        SynthConstants.SELECTED);
+                icon = b.getSelectedIcon();
             }
         }
+
         if (icon == null) {
-            icon = getIcon(b, b.getDisabledIcon(), defaultIcon,
-                    SynthConstants.DISABLED);
+            icon = specificIcon;
+        }
+
+        if (icon != null) {
+            return icon;
         }
-        return icon;
+
+        if (defaultIcon == null || defaultIcon instanceof UIResource) {
+            if (selected) {
+                icon = getSynthIcon(b, state | SynthConstants.SELECTED);
+                if (icon == null) {
+                    icon = getSynthIcon(b, SynthConstants.SELECTED);
+                }
+            }
+            if (icon == null) {
+                icon = getSynthIcon(b, state);
+            }
+        }
+
+        return icon != null ? icon : defaultIcon;
     }
 
     /**