8214111: There is no icon in all JOptionPane target image
authorpbansal
Fri, 18 Jan 2019 13:36:16 +0530
changeset 53667 6dae74bb8a43
parent 53666 1a1c393b5c42
child 53668 ac04efe9feed
8214111: There is no icon in all JOptionPane target image Reviewed-by: serb, psadhukhan
src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
--- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Tue Jan 15 22:54:08 2019 -0800
+++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java	Fri Jan 18 13:36:16 2019 +0530
@@ -1167,13 +1167,24 @@
         ICONS_MAP = new HashMap<String, GTKStockIcon>();
         ICONS_MAP.put("FileChooser.cancelIcon", new GTKStockIcon("gtk-cancel", 4));
         ICONS_MAP.put("FileChooser.okIcon",     new GTKStockIcon("gtk-ok",     4));
-        ICONS_MAP.put("OptionPane.errorIcon", new GTKStockIcon("gtk-dialog-error", 6));
-        ICONS_MAP.put("OptionPane.informationIcon", new GTKStockIcon("gtk-dialog-info", 6));
-        ICONS_MAP.put("OptionPane.warningIcon", new GTKStockIcon("gtk-dialog-warning", 6));
-        ICONS_MAP.put("OptionPane.questionIcon", new GTKStockIcon("gtk-dialog-question", 6));
         ICONS_MAP.put("OptionPane.yesIcon", new GTKStockIcon("gtk-yes", 4));
         ICONS_MAP.put("OptionPane.noIcon", new GTKStockIcon("gtk-no", 4));
         ICONS_MAP.put("OptionPane.cancelIcon", new GTKStockIcon("gtk-cancel", 4));
         ICONS_MAP.put("OptionPane.okIcon", new GTKStockIcon("gtk-ok", 4));
+
+        //check whether the gtk version is >= 3.10 as the Icon names were
+        //changed from this version
+        UNIXToolkit tk = (UNIXToolkit)Toolkit.getDefaultToolkit();
+        if (tk.checkGtkVersion(3, 10, 0)) {
+            ICONS_MAP.put("OptionPane.errorIcon", new GTKStockIcon("dialog-error", 6));
+            ICONS_MAP.put("OptionPane.informationIcon", new GTKStockIcon("dialog-information", 6));
+            ICONS_MAP.put("OptionPane.warningIcon", new GTKStockIcon("dialog-warning", 6));
+            ICONS_MAP.put("OptionPane.questionIcon", new GTKStockIcon("dialog-question", 6));
+        } else {
+            ICONS_MAP.put("OptionPane.errorIcon", new GTKStockIcon("gtk-dialog-error", 6));
+            ICONS_MAP.put("OptionPane.informationIcon", new GTKStockIcon("gtk-dialog-info", 6));
+            ICONS_MAP.put("OptionPane.warningIcon", new GTKStockIcon("gtk-dialog-warning", 6));
+            ICONS_MAP.put("OptionPane.questionIcon", new GTKStockIcon("gtk-dialog-question", 6));
+        }
     }
 }