u.icon = "" on label correctly reset icon 39/14039/2
Antoine ELIAS [Fri, 14 Mar 2014 19:39:07 +0000 (20:39 +0100)]
Change-Id: I2813c171f0eb13b4b315b21e8110aa677736a348

scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/label/SwingScilabLabel.java

index 7ba4190..a4db88d 100644 (file)
@@ -527,15 +527,20 @@ public class SwingScilabLabel extends JScrollPane implements SwingViewObject, Si
         switch (property) {
             case __GO_UI_ICON__: {
                 if (isJLabel) {
-                    File file = new File((String) value);
-                    if (file.exists() == false) {
-                        String filename = FindIconHelper.findImage((String) value);
-                        file = new File(filename);
-                    }
-
-                    try {
-                        ((JLabel) label).setIcon(new ImageIcon(ImageIO.read(file)));
-                    } catch (IOException e) {
+                    String icon = (String) value;
+                    if (icon != null && icon.equals("") == false) {
+                        File file = new File((String) value);
+                        if (file.exists() == false) {
+                            String filename = FindIconHelper.findImage((String) value);
+                            file = new File(filename);
+                        }
+
+                        try {
+                            ((JLabel) label).setIcon(new ImageIcon(ImageIO.read(file)));
+                        } catch (IOException e) {
+                        }
+                    } else {
+                        ((JLabel) label).setIcon(null);
                     }
                 } else {
                     //Icon in JEditorPane ?