Skip to content

Commit

Permalink
Use Arrays.equals for comparison of choice arrays in SwingChoiceWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
karlduderstadt committed Oct 22, 2020
1 parent 65cafca commit 9b88a14
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/main/java/org/scijava/ui/swing/widget/SwingChoiceWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;

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

if (!areListsEqual(choices, comboBoxItems())) {
if (!Arrays.equals(choices, comboBoxItems())) {
comboBox.removeAllItems();
for (int i=0; i<choices.length; i++)
comboBox.addItem(choices[i]);
Expand All @@ -113,17 +114,6 @@ public void doRefresh() {
}
}

private boolean areListsEqual(String[] list1, String[] list2) {
if (list1.length != list2.length)
return false;

for (int i=0; i< list1.length; i++)
if (!list1[i].equals(list2[i]))
return false;

return true;
}

private String[] comboBoxItems() {
String[] comboItems = new String[comboBox.getItemCount()];
for (int i=0; i <comboBox.getItemCount(); i++)
Expand Down

0 comments on commit 9b88a14

Please sign in to comment.