Here you can find the source of askForAStringInArray(String question, String header, Object[] options, String errorMessage, String errorHeader)
Parameter | Description |
---|---|
question | the question to ask |
header | the header of the box |
options | the options the user can chose from |
errorMessage | the error message when something is wrong |
errorHeader | the error message header box when something is wrong |
public static int askForAStringInArray(String question, String header, Object[] options, String errorMessage, String errorHeader)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { /**/*from w ww. jav a 2s.c o m*/ * Ask in a swing gui for something in array * @param question the question to ask * @param header the header of the box * @param options the options the user can chose from * @param errorMessage the error message when something is wrong * @param errorHeader the error message header box when something is wrong * @return the value found */ public static int askForAStringInArray(String question, String header, Object[] options, String errorMessage, String errorHeader) { int res = JOptionPane.CLOSED_OPTION; while (res == JOptionPane.CLOSED_OPTION) { res = JOptionPane.showOptionDialog(null, question, header, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, //do not use a custom Icon options, //the titles of buttons options[0]); //default button title if (res == JOptionPane.CLOSED_OPTION) { JOptionPane.showMessageDialog(null, errorMessage, errorHeader, JOptionPane.ERROR_MESSAGE); } } return res; } }