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
Solved

Disable auto close of JOptionPane

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

837 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