❮ Previous Next ❯

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

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved