Solved

Disable auto close of JOptionPane

Posted on 2004-04-25
3
877 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
[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
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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 102
null output 3 43
junit example issue 2 29
Java List 4 43
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

697 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