标题:[求助]AWT监听器问题
只看楼主
wodqqdiul
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2007-11-6
 问题点数:0 回复次数:0 
[求助]AWT监听器问题

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);
}

}


}

搜索更多相关主题的帖子: AWT 监听 
2007-11-08 22:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-184657-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.491233 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved