Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane: action on cancel for Input dialog  RSS feed

 
Jeevan Anand
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JOptionPane.showInputDialog() to get an input value. It is having OK, cancel button. Is there any way, I can know cancel button is pressed, since i want to perform some actions when cancel is pressed.

Again, when close on right top corner is pressed, Is there any way, I can know close is pressed.
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the API? Because the answer is right there, in the showInputDialog with the most parameters:
Returns:
user's input, or null meaning the user canceled the input

That also includes pressing the close button; only if OK was pressed will the returned value not be null.
 
Jeevan Anand
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!