Java Swing Tutorial Explaining the JComboBox Component. JComboBox is like a drop down box — you can click a drop-down arrow and select an option from a list. It generates ItemEvent. For example, when the component has focus, pressing a key that corresponds to the first character in some entry’s name selects that entry. A vertical scrollbar is used for longer lists.
JComboBox Source Code
import java.awt.*; |
Output
Download JComboBox Source Code
Another Example: JComboBox Source Code
import java.awt.*; |
Output
Download JComboBox Source Code
Java JComboBox Hierarchy
javax.swing
Class JComboBox
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JComboBox
All Implemented Interfaces:
Accessible, ActionListener, EventListener, ImageObserver, ItemSelectable, ListDataListener, MenuContainer, Serializable
JComboBox Constructor
JComboBox()
Creates a JComboBox with a default data model.
JComboBox(ComboBoxModel aModel)
Creates a JComboBox that takes it’s items from an existing ComboBoxModel.
JComboBox(Object[] items)
Creates a JComboBox that contains the elements in the specified array.
JComboBox(Vector items)
Creates a JComboBox that contains the elements in the specified Vector.
Đăng nhận xét