| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 821 人关注过本帖
标题:JAVA的choice怎么搞!!
只看楼主 加入收藏
huahua520
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-3-24
收藏
 问题点数:0 回复次数:0 
JAVA的choice怎么搞!!

import java.awt.*;
import java.awt.event.*;

public class ChoiceDemo extends Frame
implements ItemListener {
Choice choice;
Label label;

public ChoiceDemo(String title){
super(title);
}

public void creat() {
choice = new Choice();
choice.addItem("中国");
choice.addItem("美国");
choice.addItem("俄罗斯");
choice.addItem("加拿大");

choice.addItemListener(this);

label = new Label();
setLabelText(choice.getSelectedIndex(),
choice.getSelectedItem());


setLayout(new FlowLayout());
add(choice);
add(label);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
setSize(400,100);
setVisible(true);
}

//更新Label的内容。
void setLabelText(int num, String text) {
label.setText("Item #" + num + " selected. "
+ "Text = \"" + text + "\".");
}

//ItemListener的事件处理方法。
public void itemStateChanged(ItemEvent e) {
setLabelText(choice.getSelectedIndex(),
choice.getSelectedItem());
}
{
public void fu()1
switch(num){
case 1:System.out.println("你是八狨");break;
case 2:System.out.println("你是八狨");break;
case 3:System.out.println("你真孙悟空");bueak;
case 4:System.out.println("你是八狨");break;
}
{


public static void main(String[] args){
ChoiceDemo cd = new ChoiceDemo("Choice test");
void fu1();
cd.creat();
}
}

搜索更多相关主题的帖子: JAVA choice 
2006-03-24 15:20
快速回复:JAVA的choice怎么搞!!
数据加载中...
 
   



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

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