Here you can find the source of quitConfirmed(Component parent, String message)
Parameter | Description |
---|---|
parent | - parent component |
message | - message to use instead of default |
public static boolean quitConfirmed(Component parent, String message)
//package com.java2s; /*//from w w w. ja v a 2s. c om * ome.formats.importer.gui.GuiCommonElements * *------------------------------------------------------------------------------ * Copyright (C) 2006-2008 University of Dundee. All rights reserved. * * * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. * *------------------------------------------------------------------------------ */ import java.awt.Component; import javax.swing.JOptionPane; public class Main { /** * Quit Confirmation pop up dialog * * @param parent - parent component * @param message - message to use instead of default * @return boolean if quit (true) or cancel dialog (false) */ public static boolean quitConfirmed(Component parent, String message) { if (message == null) { message = "Do you really want to close the application?\n" + "Doing so will cancel any running imports."; } String s1 = "No"; String s2 = "Yes"; Object[] options = { s2, s1 }; int n = JOptionPane.showOptionDialog(parent, message, "Exit Application", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, s1); //b/c of switch of location if (n == JOptionPane.YES_OPTION) { return true; } else { return false; } } }