in listbox and popupmenu, color must start by #
[scilab.git] / scilab / modules / gui / src / java / org / scilab / modules / gui / bridge / listbox / SwingScilabListBox.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]);
                         }
                     }