问题在代码注释中。
- import java.awt.*;
- import java.awt.event.*;
- class AwtDemo
- {
- public static void main(String[] args)
- {
- Frame f = new Frame();
- f.setSize(400,300);
- f.setLocation(300,200);
- f.setLayout(new FlowLayout());
- Button b = new Button("anniu");
- f.add(b);
- f.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- System.out.println("windowListener");
- // 如果写成这样:System.out.println("windowListener"+e.toString());会报错,变量e错误
- }
- });
- f.setVisible(true);
复制代码
|
|