in listbox and popupmenu, color must start by # 06/14006/2
Antoine ELIAS [Thu, 13 Mar 2014 11:18:54 +0000 (12:18 +0100)]
Change-Id: I47a6352641d403bdd2d34510cf8d5e76d517cb5f

scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/listbox/SwingScilabListBox.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/popupmenu/SwingScilabPopupMenu.java

index 53a56e6..f676960 100644 (file)
@@ -413,6 +413,11 @@ public class SwingScilabListBox extends JScrollPane implements SwingViewObject,
 
             if (tryColorBox) { //color
                 try {
+                    //format #FFFFFF
+                    if (text[i].startsWith("#") == false) {
+                        throw new NumberFormatException();
+                    }
+
                     Color color = Color.decode(text[i]);
                     icon = ColorBox.createColorBox(16, 16, color);
                 } catch (NumberFormatException e) {
@@ -445,8 +450,15 @@ public class SwingScilabListBox extends JScrollPane implements SwingViewObject,
 
                     str = text[(nbRow * colIndex) + i];
                     if (nbCol > (1 + colIndex)) {
+                        if (text[nbRow * (1 + colIndex) + i].startsWith("#") == false) {
+                            throw new NumberFormatException();
+                        }
+
                         background = Color.decode(text[nbRow * (1 + colIndex) + i]);
                         if (nbCol > (2 + colIndex)) {
+                            if (text[nbRow * (2 + colIndex) + i].startsWith("#") == false) {
+                                throw new NumberFormatException();
+                            }
                             foreground = Color.decode(text[nbRow * (2 + colIndex) + i]);
                         }
                     }
index 776847a..d05335d 100644 (file)
@@ -353,6 +353,11 @@ public class SwingScilabPopupMenu extends JComboBox implements SwingViewObject,
 
             if (tryColorBox) { //color
                 try {
+                    //format #FFFFFF
+                    if (text[i].startsWith("#") == false) {
+                        throw new NumberFormatException();
+                    }
+
                     Color color = Color.decode(text[i]);
                     icon = ColorBox.createColorBox(16, 16, color);
                 } catch (NumberFormatException e) {
@@ -385,8 +390,16 @@ public class SwingScilabPopupMenu extends JComboBox implements SwingViewObject,
 
                     str = text[(nbRow * colIndex) + i];
                     if (nbCol > (1 + colIndex)) {
+                        if (text[nbRow * (1 + colIndex) + i].startsWith("#") == false) {
+                            throw new NumberFormatException();
+                        }
+
                         background = Color.decode(text[nbRow * (1 + colIndex) + i]);
                         if (nbCol > (2 + colIndex)) {
+                            if (text[nbRow * (2 + colIndex) + i].startsWith("#") == false) {
+                                throw new NumberFormatException();
+                            }
+
                             foreground = Color.decode(text[nbRow * (2 + colIndex) + i]);
                         }
                     }