草庐IT

showConfirmDialog

全部标签

java - JOptionPane showConfirmDialog 只有一个按钮

我只需要在showConfirmDialog中有一个按钮。我试过这个:intresponse=JOptionPane.showConfirmDialog(null,"TimeEnteredSuccessfully","",JOptionPane.OK_OPTION,JOptionPane.PLAIN_MESSAGE);if(response==JOptionPane.CLOSED_OPTION||response==JOptionPane.OK_OPTION){System.out.println("CLOSING>>>>>>");}但这显示带有Yes_No_option的对话框。我只

java - 如何使 JOptionPane.showConfirmDialog 默认没有选中?

我在Java中实现了一个“另存为”对话框,该对话框会提示用户文件是否已存在,并且我希望默认选择“否”选项。我该怎么做?这是我当前的代码:JFileChooserchooser=newJFileChooser(){publicvoidapproveSelection(){FileselectedFile=getSelectedFile();if(selectedFile!=null&&selectedFile.exists()){intresponse=JOptionPane.showConfirmDialog(this,"Thefile"+selectedFile.getName()+