import java.awt.*;
import java.awt.event.*;
public class ChoiceDemo extends Frame implements ItemListener,WindowListener{
Choice os;
Label L;
ChoiceDemo(){
super("Choice Selection");
setSize(400,500);
setLayout(new FlowLayout());
os=new Choice();
L=new Label(" ");
os.add("Canada");
os.add("America");
os.add("United Kindom");
os.add("Australia");
os.add("Pakistan");
add(os);
add(L);
setVisible(true);
os.addItemListener(this);
addWindowListener(this);
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void itemStateChanged(ItemEvent e){
L.setText(os.getSelectedItem());
}
public static void main(String ar[]){
ChoiceDemo cH=new ChoiceDemo();
}
}
No comments:
Post a Comment