Java tutorial
//package com.java2s; /* * 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]); } }