Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to manage the dissmissal of joptionpane when any button is clicked  RSS feed

 
Kenneth Owino
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! is there a way to manage the buttons of JOptionPane such that they do not just close when any of them is closed. For example I'm creating a program whereby the user enters username and password through JOptioPane which should only be dismissed if the user enters correct values and clicks ok or when the user clicks cancel. The problem is by default clicking any button dismisses the dialog. I've done all the necessary work of accessing the database and comparing database values with user values when ok is clicked but I don't know how to control the dialog not to dimiss after ok is clicked and username and password don't match. The code fragment for my JOptionPane is shown below
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easiest way: don't use JOptionPane#showConfirmDialog, use a modal JDialog. Alternatively redisplay the JOptionPane in a loop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!