Reputation: 2883
This code is working. but the problem is when NO_OPTION is selected then the window is disposed. I want to retain the window when NO_OPTION is selected? can u give any suggestion?
int dialogButton = JOptionPane.YES_NO_OPTION;
JOptionPane.showConfirmDialog (null, "First Row Will Selected As Default!! Do You Want To Close?","Warning",dialogButton);
if(dialogButton == JOptionPane.YES_OPTION){
int row = table.getSelectedRow();
int col = table.getSelectedColumn();
finalOID=(String)table.getModel().getValueAt(row, col);
System.out.println("cancel clicked first oid:"+finalOID);
dispose();
}
Upvotes: 2
Views: 2223
Reputation: 2883
int dialogButton = JOptionPane.showConfirmDialog (null, "First Row Will Selected As Default!! Do You Want To Close?","Warning",JOptionPane.YES_NO_OPTION);
This will fulfill the requirement
Upvotes: 4
Reputation: 205885
You may want the JOptionPane.YES_NO_CANCEL_OPTION
, illustrated in How to Make Dialogs.
Upvotes: 3