Solved

Disable auto close of JOptionPane

Posted on 2004-04-25
3
867 Views
Last Modified: 2007-12-19
sample code as below:

String[] options = {"OK","CANCEL"};
            int input = JOptionPane.showOptionDialog(
                null,   // parentComponent
                newRecordPanel, // message
                "New", // title
                JOptionPane.OK_CANCEL_OPTION,   // optionType
                JOptionPane.PLAIN_MESSAGE,    // messageType
                null,   // icon
                options,    // options
                options[0]  // initialValue
            );

i will do some validation when user click on OK button, if the validation is fail then the JOptionPane show remain there (do not close it). But how can i disable the auto close of the JOptionPane?

thanks
0
Comment
Question by:Kennywen
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10915089
easiest would be to redisplay pane when validationn fails
0
 
LVL 16

Accepted Solution

by:
gnoon earned 25 total points
ID: 10915208
do {

    String[] options = {"OK","CANCEL"};
    int input = JOptionPane.showOptionDialog(
                null,   // parentComponent
                newRecordPanel, // message
                "New", // title
                JOptionPane.OK_CANCEL_OPTION,   // optionType
                JOptionPane.PLAIN_MESSAGE,    // messageType
                null,   // icon
                options,    // options
                options[0]  // initialValue
    );

} while ( input == 0 && !valid( inputvalue ) ); // do again if OK is clicked and not valid input occur
0
 
LVL 16

Expert Comment

by:gnoon
ID: 10915219
just an example of objects's comment.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 59
word0 challenge 4 53
micro services vs rest web services 16 48
ArrayIndexOutOfBoundException 9 33
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 video teaches viewers about errors in exception handling.

706 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

18 Experts available now in Live!

Get 1:1 Help Now