按钮事件的错误~请大家帮忙?

wth1150 2005-05-30 09:57:33
import java.awt.*;
import java.awt.event.*;

public class wth
{

public static void main(String args[])
{
Frame a=new Frame("afdasf");
a.setSize(400,300);
a.show();
a.setLayout(null);
Button f1= new Button("dsaf");
f1.setBounds(70,70,70,25);
f1.addActionListener(new ActionListener()
{
public abstract void actionPerformed(ActionEvent e)

/*should be declared abstract; it does not define actionPerformed(java.awt.event.ActionEvent) in public abstract void actionPerformed(ActionEvent e)
*/
public abstract void actionPerformed(ActionEvent e)
{
if (e.getSource()=f1)
{
f2.setText("fasa");
}
}


});

a.add(f1);
TextField f2=new TextField(100);
f2.setBounds(50,50,50,50);


a.add(f2);

a.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{System.exit(0);}

});

}
}
...全文
28 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wth1150 2005-05-30
  • 打赏
  • 举报
回复
谢谢
初学者~
loveyousomuch 2005-05-30
  • 打赏
  • 举报
回复
e.getSource()=f1

基本错误
e.getSource()==f1

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧