求Java高手帮忙解释下这是为什么?我编写一段代码编译时总是提示new MyWindownListener错误,帮忙看下.
importjava.awt.*;importjava.awt.event.*;publicclassA{publicstaticvoidmain(String[]arg...
import java.awt.*;
import java.awt.event.*;
public class A
{
public static void main(String [] args)
{
Frame f=new Frame("人才交流中心");
f.add(new Button("提交"));
f.setSize(300,300);
f.setVisible(true);
f.addWindowListenner(new MyWindowListener());
}
}
class MyWindowLisenner extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
e.getWindow().setVisible(false);
((Window)e.getComponent()).dispose();
System.exit(0);
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
} 展开
import java.awt.event.*;
public class A
{
public static void main(String [] args)
{
Frame f=new Frame("人才交流中心");
f.add(new Button("提交"));
f.setSize(300,300);
f.setVisible(true);
f.addWindowListenner(new MyWindowListener());
}
}
class MyWindowLisenner extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
e.getWindow().setVisible(false);
((Window)e.getComponent()).dispose();
System.exit(0);
}
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
} 展开
4个回答
展开全部
把 f.addWindowListenner(new MyWindowListener());
改为
f.addWindowListener(new MyWindowLisenner());
改为
f.addWindowListener(new MyWindowLisenner());
展开全部
因为拼写错误,类名是MyWindowLisenner,new的时候少了个n
展开全部
你的方法名称有问题 ,f.addWindowFocusListener(new MyWindowLisenner()); 可以看看这个是否可以
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询