Sponsered Links
Categories
Sponsered Links

Swing JCombobox

 

This Example illustrates how to create the jcombobox in swing application. The output of the program and source code are given below:

Source Code of CreateComboBox.java 

import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JComboBox;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class CreateComboBox extends JFrame {
  public CreateComboBox() {
    super("ComboBox");
    getContentPane().setLayout(new BorderLayout());
    Vector cars = new Vector();
    cars.addElement("Java");
    cars.addElement("Applet");
    cars.addElement("Swing");
    getContentPane().add(new JComboBox(cars));

    WindowListener wndCloser = new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    };
    addWindowListener(wndCloser);
    pack();
    setVisible(true);
  }

  public static void main(String argv[]) {
    new CreateComboBox();
  }
}      

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved