Solved

JOptionPane.showMessageDialog

Posted on 2004-03-30
4
1,129 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:dkim18
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 210 total points
ID: 10721037

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
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 40 total points
ID: 10721156
>> showMessageDialog(parentComponent, message, title, messageType);

Perhaps:

showMessageDialog ( parentComponent, message.toString (), title, messageType ) ;
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10721179
Thanks for the correction mayankeagle!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10721327
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question