public class MainFrame extends Frame implements ActionListener{
.......
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
........
}
在执行以上代码时this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 提示The method setDefaultCloseOperation(int) is undefined for the type
原因:
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);这个方法的参数里面写的很明确,是JFrame的方法,但是你的类却继承于Frame,而Frame中根本就没有这个方法所以肯定出错,你得把extends Frame改成extends JFrame