Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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 {
    /**
     * 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;
    }
}