当前位置: 代码迷 >> Java相关 >> 小问题就是大问题
  详细解决方案

小问题就是大问题

热度:171   发布时间:2005-10-26 17:31:00.0
小问题就是大问题
在个窗口类中的    item1.addActionListener(this);
 this是代表的什么啊
----------------解决方案--------------------------------------------------------
this 是实现了 ActionListener 接口的类的实例
----------------解决方案--------------------------------------------------------
以下是引用a548475在2005-10-26 17:31:00的发言:
在个窗口类中的    item1.addActionListener(this);
 this是代表的什么啊

是代表对本窗口的事件的监听!!


----------------解决方案--------------------------------------------------------
class a implements ActionListener
{
JButton b = new JButton("OK");
public a()
{
b.addActionListener(this);
}
}

如果a类没有继承ActionListener接口则不能使用b.addActionListener(this);
----------------解决方案--------------------------------------------------------
2楼说的通俗易懂!!
----------------解决方案--------------------------------------------------------
  相关解决方案