Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic