匿名内部类:
package six;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class six {
public static void main(String[] args) {
new MyFrame();
}
}
class MyFrame extends Frame{
public MyFrame(){
setBackground(Color.blue);
setBounds(300,300,300,300);
setVisible(true);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.out.println("匿名内部类");
}
});
}
}
内部类:
class MyFrame extends Frame{
public MyFrame(){
setBackground(Color.blue);
setBounds(300,300,300,300);
setVisible(true);
}
class MyWindowListener