JComboBox, JTabbedPane class in javax.swing: Types of constructors, Methods

JComboBox class: JComboBox class is used to wrap a combo box in javax.swing. A combo box is a combination of a text field and a drop down list.

Constructors defined by JComboBox class:

Default constructor.

JComboBox( )

By initializing the combo box.

JComboBox(Vector v)

Method defined by JComboBox class:

addItem( ) method: It is used to add items to combo box.


void addItem(Object ob)

JTabbedPane class: JTabbedPane class is used to wrap a tabbed window in javax.swing. A tabbed pane has tabs with a title. When a tab is picked, the contents of that particular tab are displayed. In a tabbed pane only one tab can be selected at a time. It is generally used for settings and configuration.

Constructor defined by JTabbedPane class:

By using title of tabbed pane in str and component to be added is specified by com:

void addTab(String str, Component com)

Procedure for using a tabbed pane in an applet:

1) Create a JTabbedPane object.

2) For each tab, call addTab( ) to add a tab to pane.

3) Add tabbed pane to content pane of applet.

Leave a Reply