Solved

JOptionPane.showMessageDialog

Posted on 2004-03-30
4
1,123 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse package explorer vs project explorer view 2 125
Basic Java Case or If-Else statement... 3 50
even odd program using while loop 3 40
tomcat not starting 6 45
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

776 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