Solved

JOptionPane.showMessageDialog

Posted on 2004-03-30
4
1,111 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:mayankeagle
mayankeagle 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:mayankeagle
ID: 10721327
:-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now