ComboBox in java is created by Choice class.ComboBox suggest to the user for selecting one choice string depend on user choice from the giving alternatives.
We can create ComboBox in Java by using following program.
Code:
import java.awt.*;
import java.awt.event.*;
public class comboboxdemo
{
  public static void main(String[] args) 
{
    Frame frame=new Frame("Combobox");
    Label str=new Label("Here is a ComboBox:");
    Choice comb1=new Choice();
    Choice comb2=new Choice();
    frame.add(str);
    frame.add(comb1);
    frame.add(comb2);
    comb1.add("INDIA");
    comb1.add("JAPAN");
    comb1.add("USA");
    comb2.add("INDIA");
    comb2.add("JAPAN");
    comb2.add("USA");
    frame.setLayout(new FlowLayout());
    frame.setSize(300,200);
    frame.setVisible(true);
   
    }
   }

Last edited by shabbir; 15Apr2010 at 15:17.. Reason: Code blocks
luettke10 like this