This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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,
I'm unsure what to put in the brackets of my if statement.
I know how to delete the row.
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.