先贴出我的主函数:
public class threadExercise{
public static void main(String args[])
{
threadFrame myFrame= new threadFrame();
myFrame.setVisible(true);
myFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
}
}我把这段代码放在整个程序的末尾,结果,调试没有问题,但运行时,出现如下错误:
Exception in Thread "main" java.lang.NoSuchMethodError:main
但是,只要用鼠标选定上面代码随便拖动一下,再运行什么错误也没有了!下次打开程序运行又报同样的错,只要同样选定\拖动,错误又消失了....真晕了!!! 不过....只要将上述代码(主函数)放在程序的最开头,错误就不再出现,请问这是什么地方的问题呢?谢谢!
public class threadExercise{
public static void main(String args[])
{
threadFrame myFrame= new threadFrame();
myFrame.setVisible(true);
myFrame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
}
}我把这段代码放在整个程序的末尾,结果,调试没有问题,但运行时,出现如下错误:
Exception in Thread "main" java.lang.NoSuchMethodError:main
但是,只要用鼠标选定上面代码随便拖动一下,再运行什么错误也没有了!下次打开程序运行又报同样的错,只要同样选定\拖动,错误又消失了....真晕了!!! 不过....只要将上述代码(主函数)放在程序的最开头,错误就不再出现,请问这是什么地方的问题呢?谢谢!
{
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
太多层了,看不明白
{
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});这是关闭窗口的匿名内部类 是这样写没错的...
至于放在末尾为什么会出错要看整段代码才能分析的
角落里的理想
http://blog.csdn.net/zdsdiablo/
--------十分钟年华老去
=================================================================