2015-02-10
展开全部
创建一个 JComboBox 很容易看出它有哪些可用的方法,比如在 Eclipse 中打个点它就会提示方法列表。如:
JComboBox productTypes = new JComboBox();
productTypes.removeAllItems(); (这个时候打了点,略等半秒就会有方法列表)。
productTypes.addItem(new Option("001", "饮料"));
productTypes.addItem(new Option("002", "饼干"));
productTypes.addItem(new Option("003", "快餐"));
public class Option {
private final String label;
private final String value;
public Option(String label, String value) {
this.value = value;
this.label = label;
}
public String getLabel() {return this.label;}
public String getValue{) {return this.value;}
public String toString() {
return "[" + this.value + "]" + this.label;
}
}
JComboBox productTypes = new JComboBox();
productTypes.removeAllItems(); (这个时候打了点,略等半秒就会有方法列表)。
productTypes.addItem(new Option("001", "饮料"));
productTypes.addItem(new Option("002", "饼干"));
productTypes.addItem(new Option("003", "快餐"));
public class Option {
private final String label;
private final String value;
public Option(String label, String value) {
this.value = value;
this.label = label;
}
public String getLabel() {return this.label;}
public String getValue{) {return this.value;}
public String toString() {
return "[" + this.value + "]" + this.label;
}
}
追问
数据库?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询