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