Java Utililty Methods JOptionPane Confirmation

List of utility methods to do JOptionPane Confirmation

Description

The list of methods to do JOptionPane Confirmation are organized into topic(s).

Method

intshowConfirm(final Component rootComponent, final String message, final String title)
show Confirm
return showConfirm(rootComponent, message, title, JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.INFORMATION_MESSAGE);
booleanshowConfirm(String message)
show Confirm
return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, message, "Warning",
        JOptionPane.YES_NO_OPTION);
booleanshowConfirmation(Component component, String message)
show Confirmation
return JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(component), message,
        UIManager.getString("OptionPane.titleText"),
        JOptionPane.OK_OPTION | JOptionPane.CANCEL_OPTION) == JOptionPane.OK_OPTION;
booleanshowConfirmation(Component parent, String message)
Show a confirmation dialog.
boolean confirmed = false;
if (JOptionPane.showConfirmDialog(parent, message) == JOptionPane.YES_OPTION) {
    confirmed = true;
return confirmed;
booleanshowConfirmation(String msg)
show Confirmation
int res = JOptionPane.showConfirmDialog(null, msg, "Confirmation", JOptionPane.YES_NO_OPTION);
return (res == 0);
booleanshowConfirmationDialog(Component parent, String message)
Method description
int status = JOptionPane.showConfirmDialog(parent, message, null, JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.PLAIN_MESSAGE, null);
if ((status == JOptionPane.CANCEL_OPTION) || (status == JOptionPane.CLOSED_OPTION)) {
    return false;
return true;
booleanshowConfirmationDialog(String title, String question)
show Confirmation Dialog
int result = JOptionPane.showOptionDialog(null,
        new JLabel("<html><body>" + question.replaceAll("\n", "<br>") + "</body></html>"), title,
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
return result == JOptionPane.YES_OPTION;
intshowConfirmDialog(Component parentComponent, Object message, String title)
Shows a simple yes/no confirmation dialog, with the "no" option selected by default.
String[] options = { "Yes", "No" };
return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
        JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
intshowConfirmDialog(final Component parent, final String title, final String message)
Shows a confirm dialog.
return JOptionPane.showConfirmDialog(parent, message, title, JOptionPane.OK_CANCEL_OPTION);
booleanshowConfirmDialog(final Component parentComponent, final String message)
show Confirm Dialog
final int result = JOptionPane.showConfirmDialog(parentComponent, message, "Confirmation",
        JOptionPane.YES_NO_OPTION);
return result == JOptionPane.YES_OPTION;