int myConfirmDialog = JOptionPane.showConfirmDialog(all your parameters go here);

now, this integer "myConfirmDialog" stores a number which corresponds to the button clicked. the first button will...