JAVA如何从可选对话框中获取价值
您好, 我需要帮助,因为我堆栈= D这个问题我做了一个小程序,现在我做了一个小选项dialoge框,几个选项,我想保存选项你选择作为Int我怎么能这样做,这里是代码:
final JButton btnOdaberi = new JButton("Odaberi");
btnOdaberi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int t = 0;
String[] rate = {"1","2","3","4","5","6","7","8","9","10","11","12"};
int izaberi = JOptionPane.showOptionDialog(btnOdaberi, "Izaberi broj rata", "Rate",0,t,null, rate,"1");
}
提前致谢。
答案 0 :(得分:0)
您已将其保存在izaberi变量中,您只需显示它即可。 尝试:
JOptionPane.showMessageDialog(null, "Your choice was: "+(izaberi+1));
你的int izaberi下面的......