convert ColorsChooser to Java 7's generic JComboBox
parent
49f5605b27
commit
8bcf0e4f16
|
@ -4,8 +4,8 @@
|
||||||
</description>
|
</description>
|
||||||
<property environment="env"/>
|
<property environment="env"/>
|
||||||
<property name="debuglevel" value="source,lines,vars"/>
|
<property name="debuglevel" value="source,lines,vars"/>
|
||||||
<property name="target" value="1.6"/>
|
<property name="target" value="1.7"/>
|
||||||
<property name="source" value="1.6"/>
|
<property name="source" value="1.7"/>
|
||||||
<property name="lib" value="release/lib" />
|
<property name="lib" value="release/lib" />
|
||||||
<property name="groovy-version" value="2.1.6" />
|
<property name="groovy-version" value="2.1.6" />
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<icon>magarena.ico</icon>
|
<icon>magarena.ico</icon>
|
||||||
<jre>
|
<jre>
|
||||||
<path></path>
|
<path></path>
|
||||||
<minVersion>1.6.0</minVersion>
|
<minVersion>1.7.0</minVersion>
|
||||||
<maxVersion></maxVersion>
|
<maxVersion></maxVersion>
|
||||||
<jdkPreference>preferJre</jdkPreference>
|
<jdkPreference>preferJre</jdkPreference>
|
||||||
<initialHeapSize>256</initialHeapSize>
|
<initialHeapSize>256</initialHeapSize>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import support.ui.GenericJComboBox;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
@ -231,7 +232,7 @@ public class DuelDialog extends JDialog implements ActionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ColorsChooser extends GenericJComboBox<String> implements ListCellRenderer {
|
private static class ColorsChooser extends JComboBox<String> implements ListCellRenderer<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -239,9 +240,9 @@ public class DuelDialog extends JDialog implements ActionListener {
|
||||||
|
|
||||||
public ColorsChooser(final String colors) {
|
public ColorsChooser(final String colors) {
|
||||||
|
|
||||||
this.setRenderer(this);
|
setRenderer(this);
|
||||||
|
|
||||||
final List<String> items = new ArrayList<String>();
|
final Vector<String> items = new Vector<String>();
|
||||||
items.add("bug");
|
items.add("bug");
|
||||||
items.add("bur");
|
items.add("bur");
|
||||||
items.add("buw");
|
items.add("buw");
|
||||||
|
@ -279,22 +280,25 @@ public class DuelDialog extends JDialog implements ActionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setItems(items);
|
setModel(new DefaultComboBoxModel<String>(items));
|
||||||
setGenericSelectedItem(colors);
|
setSelectedItem(colors);
|
||||||
lastSelected = colors;
|
lastSelected = colors;
|
||||||
this.setFocusable(false);
|
this.setFocusable(false);
|
||||||
addActionListener(this);
|
addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSelectedItem() {
|
||||||
|
return getItemAt(getSelectedIndex());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(
|
public Component getListCellRendererComponent(
|
||||||
final JList list,
|
final JList<? extends String> list,
|
||||||
final Object value,
|
final String selectedVal,
|
||||||
final int index,
|
final int index,
|
||||||
final boolean isSelected,
|
final boolean isSelected,
|
||||||
final boolean cellHasFocus) {
|
final boolean cellHasFocus) {
|
||||||
final String selectedVal = (String) value;
|
|
||||||
|
|
||||||
if(selectedVal == SEPARATOR) {
|
if(selectedVal == SEPARATOR) {
|
||||||
return new javax.swing.JSeparator(javax.swing.JSeparator.HORIZONTAL);
|
return new javax.swing.JSeparator(javax.swing.JSeparator.HORIZONTAL);
|
||||||
} else if(DeckGenerators.getInstance().getGeneratorNames().contains(selectedVal)) {
|
} else if(DeckGenerators.getInstance().getGeneratorNames().contains(selectedVal)) {
|
||||||
|
@ -335,7 +339,7 @@ public class DuelDialog extends JDialog implements ActionListener {
|
||||||
|
|
||||||
if (SEPARATOR.equals(tempItem)) {
|
if (SEPARATOR.equals(tempItem)) {
|
||||||
// don't select separator
|
// don't select separator
|
||||||
setGenericSelectedItem(lastSelected);
|
setSelectedItem(lastSelected);
|
||||||
} else {
|
} else {
|
||||||
lastSelected = tempItem;
|
lastSelected = tempItem;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue