| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 570 人关注过本帖
标题:我的程序代码编译通不过
取消只看楼主 加入收藏
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
 问题点数:0 回复次数:2 
我的程序代码编译通不过
我是java新手,好多都不懂,下面是我自己编的简单程序代码我找不出错误,但是编译通不过,提示监听那有错误,请帮忙更正一下。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Demo extends JFrame {

public Demo(String t) {
super(t);
Container contentPane=this.getContentPane();
contentPane.setLayout(new FlowLayout());
setBackground(Color.white);
}

JButton a1=new JButton("demo1");
JButton a2=new JButton("demo2");
JButton a3=new JButton("demo3");
JLabel a4=new JLabel("demo4");
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");}
});



/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Demo beat =new Demo("good");

}

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

经过我多次修改成功了,相当感谢。

2007-06-10 18:14
xuxianyue123
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-6-9
收藏
得分:0 

好象在类里面真不能添加监听器,我试过了,放在方法里面就行了

2007-06-11 10:14
快速回复:我的程序代码编译通不过
数据加载中...
 
   



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

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