Bur*_*ras 2 java swing joptionpane
是否可以调用一个确认对话框,该对话框只有ON YES和NO选项(没有CANCEL选项)?
JOptionPane.showConfirmDialog(null, "Are you sure?")
Run Code Online (Sandbox Code Playgroud)
提供三种选择,但我只需要两种选择.
是.有可能的.
int result = JOptionPane.showConfirmDialog(null,
"Are you sure you wish to exit application?",null, JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
System.exit(0);
}
Run Code Online (Sandbox Code Playgroud)