Here you can find the source of popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption)
Parameter | Description |
---|---|
choices | An array of all the possible choices. |
defaultOption | The option that is selected when the popup opens. |
@SuppressWarnings("WeakerAccess") public static String popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; public class Main { /**/* ww w . j a va2s.co m*/ * Opens a popup window you can enter any text into and get a response. * @param defaultText The text that starts inside the box. * @return Returns the text the user entered. */ @SuppressWarnings("SameParameterValue") public static String popupPrompt(String title, String message, String defaultText) { return popupPrompt(title, message, null, defaultText); } /** * Allows the user to choose from a series of choices. * @param choices An array of all the possible choices. * @param defaultOption The option that is selected when the popup opens. * @return Returns the choice the user selected or null if the user canceled. */ @SuppressWarnings("WeakerAccess") public static String popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption) { ImageIcon icon = new ImageIcon(); Canvas frame = new Canvas(); return (String) JOptionPane.showInputDialog(frame, message, title, JOptionPane.PLAIN_MESSAGE, icon, choices, defaultOption); } }