Mega Code Archive

 
Categories / Java Tutorial / Swing
 

To displays a dialog with a list of choices in a drop-down list box

import javax.swing.JOptionPane; public class InputDialogWithDropdownListbox {   public static void main(String[] a) {     String[] choices = { "A", "B", "C", "D", "E", "F" };     String input = (String) JOptionPane.showInputDialog(null, "Choose now...",         "The Choice of a Lifetime", JOptionPane.QUESTION_MESSAGE, null, // Use                                                                         // default                                                                         // icon         choices, // Array of choices         choices[1]); // Initial choice     System.out.println(input);   } }