Here you can find the source of showConfirmDialog(String message)
Parameter | Description |
---|---|
message | The message to appear in the dialog. |
public static int showConfirmDialog(String message)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { private static JFrame frame = null; /**/* www . ja va 2 s. com*/ * Shows a confirm dialog with "Yes", "No", and "Cancel" buttons. * * @param message The message to appear in the dialog. * @return an int representing the selected value. This value will be: * JOptionPane. This can be any of the following: * YES_OPTION - if the "Yes" option was pressed. * NO_OPTION - if the "No" option was pressed. * CANCEL_OPTION - if the "Cancel" option was pressed. * DIALOG_CLOSED - if the user closed the dialog. */ public static int showConfirmDialog(String message) { return JOptionPane.showConfirmDialog(frame, message); } /** * Shows a confirm dialog with the specified buttons. * <p/> * This dialog will keep focus until the user closes it. * * @param message The message to be displayed in the dialog. * @param type The type of window. This can be any of the following: * YES_NO_CANCEL - for a dialog that has "Yes", "No", and "Cancel" options. * YES_NO - for a dialog that has "Yes" and "No" options. * OK_CANCEL - for a dialog that has "Ok" and "Cancel" options. * @return an int specifying what option was pressed. This can be any of the following: * YES_OPTION - if the "Yes" option was pressed. * NO_OPTION - if the "No" option was pressed. * OK_OPTION - if the "Ok" option was pressed. * CANCEL_OPTION - if the "Cancel" option was pressed. * DIALOG_CLOSED - if the dialog was closed without an option being pressed. */ public static int showConfirmDialog(String message, int type) { return JOptionPane.showConfirmDialog(frame, message, "Confirm", type); } }