diff --git a/src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java b/src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java index 3adb50a..86d7d88 100644 --- a/src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java +++ b/src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java @@ -67,7 +67,10 @@ public void actionPerformed(final ActionEvent e) { @Override public String getValue() { - return comboBox.getSelectedItem().toString(); + if (comboBox.getItemCount() > 0) + return comboBox.getSelectedItem().toString(); + else + return null; } // -- WrapperPlugin methods -- @@ -97,8 +100,35 @@ public boolean supports(final WidgetModel model) { @Override public void doRefresh() { - final Object value = get().getValue(); - if (value.equals(comboBox.getSelectedItem())) return; // no change - comboBox.setSelectedItem(value); + final String[] choices = get().getChoices(); + + if (!areListsEqual(choices, comboBoxItems())) { + comboBox.removeAllItems(); + for (int i=0; i