從JavaDoc中......
public static int showConfirmDialog(Component parentComponent,
Object message,
String title,
int optionType)
throws HeadlessException
Brings up a dialog where the number of choices is determined by the optionType parameter.
Parameters:
parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
message - the Object to display
title - the title string for the dialog
optionType - an int designating the options available on the dialog: YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION
Returns:
an int indicating the option selected by the user
返回類型將取決於你傳遞給optionType
參數的值
這表明你應該做這樣的事情...
int result = JOptionPane.showConfirmDialog(rootPane, "Are You Sure To Delete?", "Delete User", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
// Do something here
}
看看How to make dialogs for mor e細節...
謝謝MadProgrammer ... – Sajad 2013-05-10 07:48:49
請記住,JavaDocs和教程是你的朋友。如果您已經閱讀並且仍然卡住,您需要在您的問題中突出顯示這一點,我們會對您的努力給予更多的迴應;) – MadProgrammer 2013-05-10 11:59:33