| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 564 人关注过本帖
标题:程序代码错在哪?
取消只看楼主 加入收藏
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:3 
程序代码错在哪?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
public class demo extends JFrame {

public demo(String t) {
super(t);
Container contentPane=this.getContentPane();
contentPane.setLayout(new FlowLayout());
setBackground(Color.white);
contentPane.add(a1);
contentPane.add(a2);
contentPane.add(a3);
contentPane.add(a4);
contentPane.add(a5);
contentPane.add(a6);


a1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("xu");}
});
a2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("xian");}
});
a3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){a4.setText("yue");}
});

a5.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e) {
a6.setText("yes");
}
});
}
JButton a1=new JButton("demo1");
JButton a2=new JButton("demo2");
JButton a3=new JButton("demo3");
JLabel a4=new JLabel("demo4");
JLabel a6=new JLabel("demo6");
JCheckBox a5=new JCheckBox("demo5",false);

public static void main(String[] args) {
demo beat =new demo("good");
beat.addWindowListener(new WindowAdapter() {
                      //匿名类用于注册监听器
       public void windowClosing(WindowEvent e) {
         System.exit(0);
       }
     });
beat.setSize(500,300);
beat.setVisible(true);

}
}
搜索更多相关主题的帖子: 代码 
2007-06-11 14:54
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
得分:0 

编译后,窗口事件提示有一大堆同样的错误,什么illegal character?
把addwindowListener放在构造函数也一样。

2007-06-11 15:48
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
得分:0 
呵呵,我弄好了,代码是没错,我的ultraedit出了点问题,整了半天。谢谢各位了。
2007-06-11 16:55
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
得分:0 
的确没有什么,已经运行过了。
2007-06-11 19:44
快速回复:程序代码错在哪?
数据加载中...
 
   



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

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