JComboBox

The JComboBoxis an in-built class(component) which is used to create the combobox (drop-down list) in Swing. Generally Combo box is a combination of text fields and drop-down list.Following is the constructor for JComboBox. JComboBox(String str[])

JComboBox Example

importjavax.swing.*;
importjava.awt.event.*;
importjava.awt.*;
public class JComboBoxDemo extends JFrame
{
 String name[] = {"Akshay","Santosh","Tilan","Silan"};  //list of name. 
publicJComboBoxDemo() 
 {
JComboBoxjc = new JComboBox(name);	//initialzing combo box with list of name. 
add(jc);				//adding JComboBox to frame. 
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 300);
setVisible(true);
 }
public static void main(String[] args)
 {
newJComboBoxDemo();
 }
}

Output

pic

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252

Comment