import javax.swing.*;
import java.lang.*;
import java.awt.*;public class TestFrame extends JFrame
{
public TestFrame()
{
super();
}
public static void main(String[] args)
{
JComboBox com = new JComboBox();
Item item1 = new Item();
Item item2 = new Item("Second");
Item item3 = new Item("Third","3");
item1.setText("First");
item1.setValue("1");
item2.setValue("2");
com.addItem(item1);
com.addItem(item2);
com.addItem(item3);
com.setSize(100,20);
TestFrame f = new TestFrame();
f.getContentPane().setLayout(new FlowLayout());
f.setBounds(100,100,400,300);
f.getContentPane().add(com);
f.show();
}
}class Item extends Object
{
private String text;
private String value;

public Item()
{
this.text = null;
this.value = null;
} public Item(String text)
{
this.text = text;
this.value = null;
} public Item(String text,String value)
{
this.text = text;
this.value = value;
}

public void setText(String text)
{
this.text = text;
}

public String getText()
{
return this.text;
}

public void setValue(String value)
{
this.value = value;
}

public String getValue()
{
return this.value;
}

public String toString()
{
return this.text;
}
}