我的 JavaJComboBox
由循环数组组成
假设组合框将列出:
"Argentina Vs USA" // array[0]
"Brazil Vs Canada" // array[1]
"Canada Vs Netherland" // array[2]
"Holland Vs Netherland" // array[3]
然后一旦在..中选择了一个选项
actionPerformed(ActionEvent e){
JComboBox cb = (JComboBox)e.getSource();
String countryVScountry = (String)cb.getSelectedItem();
//I need help here, I don't want to get the String, but the
//array number instead.
//e.g. I choose "Brazil Vs Canada"
//What method should I use to make it return "1"?
//then if I choose "Holland Vs Netherland", it will return 3
}
我不想获取字符串,而是获取数组编号。例如,我选择“巴西对加拿大”
- 我应该使用什么方法使它返回“1”?
- 然后如果我选择“Holland Vs Netherland”,它将返回 3