add two value to combobox
In c# we can add a text and a value to each items of combobox, I want to know is开发者_StackOverflow社区 it possible in Java also? if not please advice.
I Solved my problem by create a class like
public class ItemInfo {
public String Name;
public String Value;
public ItemInfo(String Name , String Value) {
this.Name = Name;
this.Value = Value;
}
public String toString() {
return Name ;
}
public String getValue() {
return Value ;
}
}
than I just create a new object from this class & pass it to my combobox
combbox1.addItem(new ItemInfo(item[0],item[1]));
job done :)!
You should learn how to use ComboBox in java.
精彩评论