More helpful error message if no component is selected in LogicUICanvas
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / LogicUICanvas.java
index 8e01a16..73c1f06 100644 (file)
@@ -113,9 +113,10 @@ public class LogicUICanvas extends ZoomableCanvas
                {
                        try
                        {
-                               if (componentSelector.getSelectionIndex() >= componentsByItemIndex.size())
-                                       throw new RuntimeException("No valid component selected");
-                               GUIComponent target = componentsByItemIndex.get(componentSelector.getSelectionIndex());
+                               int componentIndex = componentSelector.getSelectionIndex();
+                               if (componentIndex < 0 || componentIndex >= componentsByItemIndex.size())
+                                       throw new RuntimeException("No component selected");
+                               GUIComponent target = componentsByItemIndex.get(componentIndex);
                                String valueString = valueText.getText();
                                Object value;
                                if (radioBit.getSelection())