有没有办法获得所选项目的选定索引时使用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