我的Java JComboBox
由循环数组构成
假设组合框将列出:
"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
}
我不想获取String,而是获取数组编号。 例如我选择“巴西对加拿大”