Java tutorial
//package com.java2s; import java.awt.Component; import javax.swing.JOptionPane; public class Main { /** * Show input dialog in item selection mode with specified title, message * and initial selection. * * @param parent * the parent component of the input dialog, set {@code null} if * not has one * @param title * the title of the dialog * @param message * the message to display * @param initial * an array of <code>Object</code>s that * gives the possible selections * @param selections * the value used to initialize the input * field * @return the selected item, or <code>null</code> if user canceled input. */ public static Object selectDialog(Component parent, String title, String message, Object initial, Object[] selections) { return JOptionPane.showInputDialog(parent, message, title, JOptionPane.INFORMATION_MESSAGE, null, selections, initial); } }