我创建了一个需要 3 个字段的自定义对话框
public class Test{
public static void main(String args[])
{
JTextField firstName = new JTextField();
JTextField lastName = new JTextField();
JPasswordField password = new JPasswordField();
final JComponent[] inputs = new JComponent[] {
new JLabel("First"),
firstName,
new JLabel("Last"),
lastName,
new JLabel("Password"),
password
};
JOptionPane.showMessageDialog(null, inputs, "My custom dialog",JOptionPane.PLAIN_MESSAGE);
System.out.println("You entered " +firstName.getText() + ", " +lastName.getText() + ", " +password.getText());
}
}
如何检查用户是否插入了所有字段?即使用户关闭它显示的对话框
You entered , ,
如果用户关闭对话框而不显示,我想检查字段中的用户输入并关闭应用程序
"You entered , , "