| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 431 人关注过本帖
标题:[求助]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
快速回复:[求助]AWT监听器问题
数据加载中...
 
   



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

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