有沒有辦法獲得所選項目的選定索引時使用JOptionPane與組合框?如何從JOptionPane中獲取所選項目的int值?
在下面的代碼中,我可以得到選定的值,但我需要選定的索引。
String input = (String) JOptionPane.showInputDialog(null, "Select Mechanic: ",
"Select Mechanic", JOptionPane.QUESTION_MESSAGE, null, mechanics, mechanics[0]);
是否可以通過JOptionPane獲取選定的索引?
經過快速Google搜索,我遇到了此StackOverFLow線程。我希望它能幫助你滿足你的要求。 http://stackoverflow.com/questions/11489845/how-to-return-index-of-object-array-used-by-joptionpane-for-use-in-a-switch-stat – Aeryes