Input dialog with user-defined logo
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class ComboBoxDialog {
public static void main(String argv[]) {
String[] plays = new String[] { "Hamlet", "King Lear",
"Otello", "Romeo and Juliet" };
String input = (String) JOptionPane.showInputDialog(
new JFrame(),
"Please select your favorite Shakespeare play",
"Title", JOptionPane.INFORMATION_MESSAGE,
new ImageIcon("java2sLogo.GIF"), plays, "Romeo and Juliet");
System.out.println("User's input: " + input);
}
}
Related examples in the same category