Java JOptionPane Warning popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption)

Here you can find the source of popupPrompt(String title, String message, @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption)

Description

Allows the user to choose from a series of choices.

License

Open Source License

Parameter

Parameter Description
choices An array of all the possible choices.
defaultOption The option that is selected when the popup opens.

Return

Returns the choice the user selected or null if the user canceled.

Declaration

@SuppressWarnings("WeakerAccess")
public static String popupPrompt(String title, String message,
        @SuppressWarnings("SameParameterValue") String[] choices, String defaultOption) 

Method Source Code


//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);
    }
}

Related

  1. displayWarningMessage(Component parentComponent, String message, String windowTitle)
  2. getIconWarning()
  3. messageWarning(String s)
  4. messageWarning(String s)
  5. popupMessage(String title, String message, @SuppressWarnings("SameParameterValue") int icon)
  6. showPrettyWarningPromptPane(Component caller, String msg)
  7. showWarning(Component owner, String msg)
  8. showWarning(Component parent, String title, String message)
  9. showWarning(final Component rootComponent, final String message, final String title)