Java tutorial
import java.awt.Font; import java.awt.GridBagLayout; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.BevelBorder; import javax.swing.border.SoftBevelBorder; public class Main { static final String COMBO_BOX_ELEMENTS[] = { "Roll", "SetCode", "Answers", "Others" }; public static void main(String[] args) { JFrame window = new JFrame("Example"); JPanel contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); JComboBox comboBoxfields = new JComboBox(COMBO_BOX_ELEMENTS); comboBoxfields.setFont(new Font("sansserif", Font.TRUETYPE_FONT | Font.PLAIN, 15)); comboBoxfields.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); comboBoxfields.setMaximumRowCount(5); comboBoxfields.addActionListener( e -> System.out.println("'" + comboBoxfields.getSelectedItem().toString() + "'" + " was selected")); contentPane.add(comboBoxfields); window.add(contentPane); window.setSize(500, 500); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); } }