Solved

JOptionPane.showMessageDialog

Posted on 2004-03-30
4
1,134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java basic valueOf question 1 50
ArrayList Adding/settign data 3 37
Find out all repos that a user is most active on Github 1 57
Java List 4 76
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

732 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