Skip to content

Commit 9b88a14

Browse files
Use Arrays.equals for comparison of choice arrays in SwingChoiceWidget
1 parent 65cafca commit 9b88a14

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import java.awt.event.ActionEvent;
3333
import java.awt.event.ActionListener;
34+
import java.util.Arrays;
3435

3536
import javax.swing.JComboBox;
3637
import javax.swing.JPanel;
@@ -102,7 +103,7 @@ public boolean supports(final WidgetModel model) {
102103
public void doRefresh() {
103104
final String[] choices = get().getChoices();
104105

105-
if (!areListsEqual(choices, comboBoxItems())) {
106+
if (!Arrays.equals(choices, comboBoxItems())) {
106107
comboBox.removeAllItems();
107108
for (int i=0; i<choices.length; i++)
108109
comboBox.addItem(choices[i]);
@@ -113,17 +114,6 @@ public void doRefresh() {
113114
}
114115
}
115116

116-
private boolean areListsEqual(String[] list1, String[] list2) {
117-
if (list1.length != list2.length)
118-
return false;
119-
120-
for (int i=0; i< list1.length; i++)
121-
if (!list1[i].equals(list2[i]))
122-
return false;
123-
124-
return true;
125-
}
126-
127117
private String[] comboBoxItems() {
128118
String[] comboItems = new String[comboBox.getItemCount()];
129119
for (int i=0; i <comboBox.getItemCount(); i++)

0 commit comments

Comments
 (0)