2

此代码正在运行。but the problem is when NO_OPTION is selected then the window is disposed. 我想在选择 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();

                }
4

2 回答 2

4
int dialogButton = JOptionPane.showConfirmDialog (null, "First Row Will Selected As Default!! Do You Want To Close?","Warning",JOptionPane.YES_NO_OPTION);

这将满足要求

于 2012-09-07T05:45:29.857 回答
3

您可能需要如何制作对话框JOptionPane.YES_NO_CANCEL_OPTION中的说明。

于 2012-09-06T13:39:34.140 回答