Friday, 14 February 2014

Java JComboBox


Above image displays an example of a JComboBox. It has only two items (Private and Commercial)

private String[] types = {"Private", "Commercial"}
private JComboBox connectionTypes =  = new JComboBox(types);
connectionTypes .setSelectedIndex(0);

If some action has to be performed on item selection
connectionTypes .addActionListener(new SomeActionListener());

A complete code example for JComboBox can be found in this post link -> ComboBox Example

No comments:

Post a Comment