我试图制作一个要求10以上数字的程序,然后显示相关的对话框。这就是我到目前为止所做的事情,而且我不知道自己是否走在正确的轨道上。
int userInput;
if ( userInput < 10)
{
JOptionPane.showMessageDialog(null,
"Thank you.", "Confirmation",
JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null,
"Your number is not big enough", "Confirmation",
JOptionPane.INFORMATION_MESSAGE);
}
如何让Java请求输入?
答案 0 :(得分:2)
查看JOptionPane.showInputDialog
:
请参阅Getting the User's Input from a Dialog教程
中的How to Make DialogsString userInput = JOptionPane.showInputDialog(null, "Enter a number.");