JOptionPane.showMessageDialog

I have six JTextFields on JPanel and I need to verify all inputs in JTextFields.
Depend on validation of inputs, my program need generate JOptionPane.showMessageDialog. However, there so many different cases, and I can't write JOptionPane.showMessageDialog for each different case.
My qustion is how do I get all different dialog message by using only one JOptionPane.showMessageDialog statement?

For example, if a user didn't put anything and just press 'verify' button, JOptionPane.showMessageDialog should show all six different mssages. If a user put  threee valid inputs, then three messages for invalid input should be on JOptionPane.
dkim18Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mmuruganandamConnect With a Mentor Commented:

String lineSeparator = System.getProperty("line.separator");
StringBuffer message = new StringBuffer();
message.append("message 1");
message.append(lineSeparator);
message.append("message 2");
message.append(lineSeparator);
-
-
-
message.append("message 6");

showMessageDialog(parentComponent, message, title, messageType);


This way, you can show all the messages in one message box.

0
 
Mayank SConnect With a Mentor Associate Director - Product EngineeringCommented:
>> showMessageDialog(parentComponent, message, title, messageType);

Perhaps:

showMessageDialog ( parentComponent, message.toString (), title, messageType ) ;
0
 
mmuruganandamCommented:
Thanks for the correction mayankeagle!
0
 
Mayank SAssociate Director - Product EngineeringCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.