package sample;
import java.awt.*;
import java.awt.event.*;
public class ResumeFrame{
Frame f;
Button north, west, center;
Choice c;
public static void main(String[] args){
ResumeFrame rm = new ResumeFrame();
rm.go();
}
public void go(){
f = new Frame("ResumeFrameTest");
f.setSize(300,300);
Label north = new Label("ResumeFrame");
f.add(BorderLayout.NORTH,north);
c = new Choice();
c.add("Objective");
c.add("Qualification");
c.add("Working Experience");
c.add("Education");
c.add("Certification");
c.addItemListener(new MyItemListener());
f.add(BorderLayout.WEST,c);
Panel panel = new Panel(new CardLayout());
TextArea n1 = new TextArea("OOOOO");
TextArea n2 = new TextArea("QQQQQ");
TextArea n3 = new TextArea("WWWWW");
TextArea n4 = new TextArea("EEEEE");
TextArea n5 = new TextArea("CCCCC");
panel.add(n1,"OOOOO");
panel.add(n1,"QQQQQ");
panel.add(n1,"WWWWW");
panel.add(n1,"EEEEE");
panel.add(n1,"CCCCC");
f.add(BorderLayout.CENTER,panel);
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
f.setVisible(false);
f.dispose();
System.exit(0);
}
});
}
class MyItemListener implements ItemListener {
public void itemStateChanged(ItemEvent e){
Choice c = (Choice)e.getSource();
String itemname = c.getSelectedItem();
CardLayout cl = ((CardLayout)panel)center.getLayout();//这里应该怎么处理?
cl.show(panel,itemname);
}
}
}