Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple JOptionPane help

 
charlie mills
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created a dialog box with the options YES/NO but I now I want to perform another task depending on which button the users clicked.
I think I need an if statement saying:
if yes is clicked
then delete row,
if no is clicked,
do nothing.

I'm unsure what to put in the brackets of my if statement.
I know how to delete the row.

Sorry if i haven't explained this very well.
 
Paul Clapham
Sheriff
Pie
Posts: 20966
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's start with the code which creates the dialog box.
 
charlie mills
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm just not sure what to put in the brackets of my if statement.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Charlie!

Champion, I believe you are looking for something like this:

 
charlie mills
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roberto.
That's exactly what I was looking for!
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:Howdy, Charlie!

Champion, I believe you are looking for something like this:


Just as a note, the choice is not necessarily No - it can also be no choice, if the user clicked away the dialog with the little X. This will give the return value JOptionPane.CLOSED_OPTION which is different from JOptionPane.NO_OPTION. In most cases you don't care though, and will treat CLOSED_OPTION the same as NO_OPTION or CANCEL_OPTION - just as the Javadoc on CLOSED_OPTION mentions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic