私の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 が返されます。