how to show integer values in JComboBox?
- by Edan
Hello,
I would like to know how to set a JComboBox that contain integers values that I could save.
Here is the definitions of values:
public class Item
{
private String itemDesc;
private int itemType;
public static int ENTREE=0;
public static int MAIN_MEAL=1;
public static int DESSERT=2;
public static int DRINK=3;
private float price;
int[] itemTypeArray = { ENTREE, MAIN_MEAL, DESSERT, DRINK };
Object[][] data = {{itemDesc, new Integer(itemType), new Float(price)}};
.
.
.
}
Now, I want the add a JComboBox that the user will choose 1 of the items (ENTREE, MAIN_MEAL...) and then I could set the number as an Integer.
I know that JComboBox need to be something like that:
JComboBox combo = new JComboBox(itemTypeArray.values());
JOptionPane.showMessageDialog( null, combo,"Please Enter Item Type", `JOptionPane.QUESTION_MESSAGE);`
What am I doing wrong?