Java JOptionPane Message noTo(String message)

Here you can find the source of noTo(String message)

Description

Displays a confirmation window asking a user a yes or no question.

License

Open Source License

Parameter

Parameter Description
message the message to show.

Return

true if "no" was clicked. false otherwise.

Declaration

public static boolean noTo(String message) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2014 Black Rook Software
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 ******************************************************************************/

import java.awt.Component;

import javax.swing.JOptionPane;

public class Main {
    /**//www .ja  va 2s. com
     * Displays a confirmation window asking a user a yes or no question.
     * This is a convenience method for code readability, and is completely
     * equivalent to !yesTo(message).
     * @param message   the message to show.
     * @return         true if "no" was clicked. false otherwise.
     */
    public static boolean noTo(String message) {
        return !yesTo(message);
    }

    /**
     * Displays a confirmation window asking a user a yes or no question.
     * This is a convenience method for code readability, and is completely
     * equivalent to !yesTo(message,parent).
     * @param message   the message to show.
     * @param parent   Parent component of this dialog.
     * @return         true if "no" was clicked. false otherwise.
     */
    public static boolean noTo(String message, Component parent) {
        return !yesTo(message, parent);
    }

    /**
     * Displays a confirmation window asking a user a yes or no question.
     * @param message   the message to show.
     * @return         true if "yes" was clicked. false otherwise.
     */
    public static boolean yesTo(String message) {
        return yesTo(message, null);
    }

    /**
     * Displays a confirmation window asking a user a yes or no question.
     * @param message   the message to show.
     * @param parent   Parent component of this dialog.
     * @return         true if "yes" was clicked. false otherwise.
     */
    public static boolean yesTo(String message, Component parent) {
        int c = JOptionPane.showConfirmDialog(parent, message, "Confirm", JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        boolean out = c == JOptionPane.YES_OPTION;
        return out;
    }
}

Related

  1. msgbox(Object message)
  2. msgBox(String msg)
  3. msgBox(String title, String message)
  4. msgChoice(int options, String title, String msg, String item, String sep)
  5. notImplemented(final String message)
  6. optionWindow(String message, String title, String[] options)
  7. pause(final String msg)
  8. plain(String title, Object message, JComponent parent)
  9. popup(Component parent, String message, String title)