I have created a custom dialog box which requires 3 fields
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());
}
}
How do I check if the user has inserted all fields or not? And even if user close the dialog box it display
You entered , ,
I want to check user input in field and close application if user close dialog box without dsplaying
"You entered , , "
You can check if user has inserted all fields or not as follows:
EDIT:
For displaying a message after closing the dialog box, you can do it like:
EDIT2:
OK, I think I understand your question now, try this: