joptionpane和确认对话框,是没有按钮

时间:2012-09-06 12:52:52

标签: java swing joptionpane

此代码正常运行。但问题是当选择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();

                }

2 个答案:

答案 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}}。