Example Code #2 – JOptionPane JCombobox
by Samet Kilictas on Dec.21, 2008, under Java, Programming
This code shows how to add ComboBox property to JOptionPane.showInputDialog. And the class is able to take an input from this combobox
import javax.swing.JOptionPane;
public class Options {
public Options() {
String smallList[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thrusday", "Friday", "Saturday" };
String value = (String)JOptionPane.showInputDialog(
null,
"What is your favourt day?",
"Which day?",
JOptionPane.QUESTION_MESSAGE,
null, // Use default icon
smallList,
smallList[smallList.length-1]);
JOptionPane.showMessageDialog(null,
"Your favourit Day: " + value);
}
public static void main(String[] args) {
new Options();
}
}
No comments for this entry yet...
Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the 