如何从下拉列表中选择一个字符串,并将其传递给具有字符串数组的对象类?
例如
服务等级
JComboBox comboBox = new JComboBox();
for (int i = 0; i < 3; i++)
{
comboBox.addItem(Rma.warrantyStatus[i]);
}
comboBox.setBounds(123, 57, 116, 20);
Add.add(comboBox);
在对象类中
String[] warrantyStatus = {"In warranty", "Out of warranty", "DOA"};
public String[] getWarrantyStatus() {
return warrantyStatus;
}
public void setWarrantyStatus(String[] warrantyStatus) {
this.warrantyStatus = warrantyStatus;