public boolean action(Event e,Object O)
{
if (e.target instanceof Button)
{
Button buttAct=(Button)e.target;
//修改 if (((String)buttAct.getLable()).equals("Exit"))
System.exit(0);
}
return true;
}
{
if (e.target instanceof Button)
{
Button buttAct=(Button)e.target;
//修改 if (((String)buttAct.getLable()).equals("Exit"))
System.exit(0);
}
return true;
}
解决方案 »
- Graphics问题
- 刚刚接触正则希望高手指点。没有分数了。不好意思了
- 我对System.in.read()不太会用,请赐教!
- 问个问题,关于对象成员引用的,谁帮看下?
- 为什么我在windows2003上安装j2sdk1.4.2的时候提示我出错,错误是什么2755
- 急急急,如何从oracle中取出存放图片的字段值,并且还原成图片
- 有什么工具可以使Java编写的程序的界面好看一点啊
- 再问一个java基础问题
- 有什么办法让Java程序在Windows下运行不需要虚拟机?
- 请问如何限制jTextFiled的输入字符的长度?
- 今天刚学java就遇到配置问题,唉!进来看看把!
- 难道这里没人了解JDO吗????
{
if (e.target instanceof Button)
{
Button buttAct=(Button)e.target;
//修改 if (((String)buttAct.getLable()).equals("Exit"))
System.exit(0);
}
return true;
}
都快被淘汰的东西了btn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.exit(0); }
});
buttExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
add(buttExit);
我这样写,还是出错,我手上的JAVA资料很少,能不能吧这部分写的详细点呀
谢谢
buttExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
add(buttExit);
我这样写,还是出错,我手上的JAVA资料很少,能不能吧这部分写的详细点呀
谢谢
是不是没有实现接口ActionListener 的抽象方法actionPerformed
symbol : class ActionListener
location: class IpMain
buttExit.addActionListener(new ActionListener()
^出错信息
symbol : class ActionListener
location: class IpMain
buttExit.addActionListener(new ActionListener()
^出错信息
if (((String)buttAct.getLable()).equals("Exit"))
也还是出错,提示:
cannot resolve symbol
symbol : class ActionListener
location: class IpMain
buttExit.addActionListener(new ActionListener()
^
public calss myclass
{
JButton add = new JButton();
JButton exit = new JButton();
add.addActionListener(this);
exit.addActionListener(this);
public myclass()
{
}
actionPerformed(ActionEvent e)
{
Object s=e.getsource();
if(s==add)
//执行你的代码
else if (s==exit)
//执行你的代码
......
}
}ok了。试试吧。这就是所谓的java里的时间监听器了。
public void actionPerformed(ActionEvent e)
提示出错:incompatible types
found : java.lang.Object
required: java.awt.Button
Button buttTmp=event.getSource();
^
1 error
1 warning
Finished