Here you can find the source of askYesNoQuestion(String dlgTitle, String question, Component parent, Object[] buttonTittle)
Parameter | Description |
---|---|
dlgTitle | -- the title of the dialog window |
question | -- the question to ask |
parent | -- the parent component |
buttonTittle | -- an string array of length 2 containing for the button. Its 1st elemtn will replace the ok and its seond element will replace the cancel |
public static boolean askYesNoQuestion(String dlgTitle, String question, Component parent, Object[] buttonTittle)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.JOptionPane; public class Main { /**/*from w w w .j a v a 2s .com*/ * Shows a yes and no dialog with a specified question * * @param dlgTitle -- the title of the dialog window * @param question -- the question to ask * @param parent -- the parent component * @param buttonTittle -- an string array of length 2 containing * for the button. Its 1st elemtn will replace the ok and * its seond element will replace the cancel * @return true for a klick on yes otherwise false. */ public static boolean askYesNoQuestion(String dlgTitle, String question, Component parent, Object[] buttonTittle) { Object[] options = { "Yes", "No" }; if (buttonTittle != null) { if (buttonTittle.length == 2) { options[0] = buttonTittle[0]; options[1] = buttonTittle[1]; } } int n = JOptionPane.showOptionDialog(parent, question, dlgTitle, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, //don't use a custom Icon options, //the titles of buttons options[0]); //default button title return (n == JOptionPane.YES_OPTION); } }