此代码正常运行。但问题是当选择NO_OPTION然后处理窗口。我想在选择NO_OPTION时保留窗口?你可以提出任何建议吗?
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();
}
答案 0 :(得分:4)
int dialogButton = JOptionPane.showConfirmDialog (null, "First Row Will Selected As Default!! Do You Want To Close?","Warning",JOptionPane.YES_NO_OPTION);
这将满足要求
答案 1 :(得分:3)
您可能想要JOptionPane.YES_NO_CANCEL_OPTION
中所示的{{1}}。