Java JOptionPane Confirmation showConfirmDialog(Component parentComponent, Object message, String title)

Here you can find the source of showConfirmDialog(Component parentComponent, Object message, String title)

Description

Shows a simple yes/no confirmation dialog, with the "no" option selected by default.

License

Open Source License

Parameter

Parameter Description
parentComponent a parameter
message a parameter
title a parameter

Declaration

public static int showConfirmDialog(Component parentComponent, Object message, String title) 

Method Source Code


//package com.java2s;
/*/*from w  w w . j  a  v a  2s  .c o m*/
 * SwingHelper.java
 * This file is part of Portecle, a multipurpose keystore and certificate tool.
 *
 * Copyright ? 2007-2014 Ville Skytt?, ville.skytta@iki.fi
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.awt.Component;

import javax.swing.JOptionPane;

public class Main {
    /**
     * Shows a simple yes/no confirmation dialog, with the "no" option selected by default. This method exists
     * only because there's apparently no easy way to accomplish that with JOptionPane's static helper
     * methods.
     * 
     * @param parentComponent
     * @param message
     * @param title
     * @see JOptionPane#showConfirmDialog(Component, Object, String, int)
     */
    public static int showConfirmDialog(Component parentComponent, Object message, String title) {
        String[] options = { "Yes", "No" };
        return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
    }
}

Related

  1. showConfirmation(Component component, String message)
  2. showConfirmation(Component parent, String message)
  3. showConfirmation(String msg)
  4. showConfirmationDialog(Component parent, String message)
  5. showConfirmationDialog(String title, String question)
  6. showConfirmDialog(final Component parent, final String title, final String message)
  7. showConfirmDialog(final Component parentComponent, final String message)
  8. showConfirmDialog(String message)
  9. showConfirmDialog(String title, String message)