使用JOptionPane请求用户输入

时间:2014-06-11 19:37:07

标签: java

我试图制作一个要求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请求输入?

1 个答案:

答案 0 :(得分:2)

查看JOptionPane.showInputDialog

请参阅Getting the User's Input from a Dialog教程

中的How to Make Dialogs
String userInput = JOptionPane.showInputDialog(null, "Enter a number.");
相关问题