File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes simple JOptionPane help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "simple JOptionPane help" Watch "simple JOptionPane help" New topic
Author

simple JOptionPane help

charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
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
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Let's start with the code which creates the dialog box.
charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49


I'm just not sure what to put in the brackets of my if statement.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Howdy, Charlie!

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



Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
charlie mills
Ranch Hand

Joined: Nov 01, 2008
Posts: 49
Thanks Roberto.
That's exactly what I was looking for!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple JOptionPane help