我已经创建了一个JOptionPane作为选择方法。我想为字符串数组的选择1,2或3的int值,所以我可以用它作为计数器。我如何获得数组的索引并将其设置为等于我的整型变量loanChoice?如何从JOptionPane中的字符串数组中选择一个索引值
public class SelectLoanChoices {
int loanChoice = 0;
String[] choices = {"7 years at 5.35%", "15 years at 5.5%",
"30 years at 5.75%"};
String input = (String) javax.swing.JOptionPane.showInputDialog(null, "Select a Loan"
,"Mortgage Options",JOptionPane.QUESTION_MESSAGE, null,
choices,
choices[0]
**loanChoice =**);
}
欢迎来到SO。突出显示代码并按下ctrl-k,以便正确渲染。 – bernie 2010-06-19 05:33:37