This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing JOptionPane. with a sentinel value.  RSS feed

 
Marge Tao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to close a JOptionPane whenever the user types in 0 or -1. I have currently set up a boolean variable and assigned it a value of false. When the user types true, I want the window to close. However, I am not sure of a method which will close JOptionPane after the sentinel value is typed. Is there a way to do this?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
generally, that's not how a JOptionPane works i.e. the entry closing it.

the 0/-1 sentinel value is usually associated with a while()


is this something like what you're trying to do?
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a reference to your JOptionPane object, you can use its setValue method. For default options, you need an Integer object with JOptionPane.OK_OPTION to simulate an OK press.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!