Java examples for Swing:JComboBox
Use a noneditable combo box from which a user can choose one from the drop down
import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Main extends JFrame { String[] formats = { "Atom", "RSS 0.92", "RSS 1.0", "RSS 2.0" }; JComboBox formatBox = new JComboBox(formats); public Main() { super("Choose a Format"); setSize(220, 150);// w w w. j ava2 s .c o m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pane = new JPanel(); JLabel formatLabel = new JLabel("Output formats:"); pane.add(formatLabel); pane.add(formatBox); add(pane); setVisible(true); } public static void main(String[] arguments) { Main ff = new Main(); } }