import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class ComboBoxTest extends JFrame
{
String n[]={"One","Two","Three"};
JComboBox num;
JPanel panel;
ComboBoxTest()
{
num=new JComboBox(n);
num.addActionListener(new ActionText());
panel=new JPanel();
getContentPane().add(panel);
panel.add(num);

pack();
setVisible(true);
}
class ActionText implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(num.getSelectedItem().equals("One"))
{
JOptionPane.showMessageDialog(null,"One");
}else if(num.getSelectedItem().equals("Two"))
{
JOptionPane.showMessageDialog(null,"Two");
}else if(num.getSelectedItem().equals("Three"))
{
JOptionPane.showMessageDialog(null,"Three");
}
}
}
public static void main(String args[])
{
new ComboBoxTest();
}
}