diff --git a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java index 4cb7a20ec8..7a453e3843 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java @@ -744,7 +744,7 @@ public class ConnectDialog extends MageDialog { DefaultComboBoxModel flagModel = (DefaultComboBoxModel)cbFlag.getModel(); String[] flagItem; - for(int i = 0; i < flagModel.getSize() - 1; i++){ + for(int i = 0; i < flagModel.getSize(); i++){ flagItem = (String[])flagModel.getElementAt(i); choiceItems.put(flagItem[1], flagItem[0]); } diff --git a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java index 1e5f70cda1..60cadbfa3d 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java @@ -181,7 +181,7 @@ public class PickChoiceDialog extends MageDialog { // start selection if((startSelectionValue != null)){ int selectIndex = -1; - for(int i = 0; i < this.listChoices.getModel().getSize() - 1; i++){ + for(int i = 0; i < this.listChoices.getModel().getSize(); i++){ KeyValueItem listItem = (KeyValueItem)this.listChoices.getModel().getElementAt(i); if (listItem.Key.equals(startSelectionValue)){ selectIndex = i; diff --git a/Mage.Client/src/main/java/mage/client/util/gui/FastSearchUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/FastSearchUtil.java index 9d88e27137..ed54815434 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/FastSearchUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/FastSearchUtil.java @@ -32,8 +32,8 @@ public class FastSearchUtil { Map choiceSorting = new HashMap<>(comboModel.getSize()); String item; - for(int i = 0; i < comboModel.getSize() - 1; i++){ - item = (String)comboModel.getElementAt(i); + for(int i = 0; i < comboModel.getSize(); i++){ + item = comboModel.getElementAt(i).toString(); choiceItems.put(item, item); choiceSorting.put(item, i); // need so sorting } @@ -44,7 +44,7 @@ public class FastSearchUtil { // current selection value restore String needSelectValue; - needSelectValue = (String)comboModel.getSelectedItem(); + needSelectValue = comboModel.getSelectedItem().toString(); // ask for new value PickChoiceDialog dlg = new PickChoiceDialog(); @@ -52,7 +52,13 @@ public class FastSearchUtil { dlg.showDialog(choice, needSelectValue); if(choice.isChosen()){ item = choice.getChoiceKey(); - comboModel.setSelectedItem(item); + + // compatible select for object's models (use setSelectedIndex instead setSelectedObject) + for(int i = 0; i < comboModel.getSize(); i++){ + if(comboModel.getElementAt(i).toString().equals(item)){ + combo.setSelectedIndex(i); + } + } } } }