![]() |
![]() |
![]() |
![]() |
![]() |
|
You can reduce still more the number of names that you need to invent by
defining inner classes that have no names at all. You use a syntactic
convention that replaces the name of the inner class in the new expression with a
definition of that inner class. Note that the definition includes the name
of the extended class, WindowAdapter:
import javax.swing.*;
import java.awt.event.*;
public class MovieApplication extends JFrame {
public static void main (String argv []) {
new MovieApplication("Movie Application");
}
public MovieApplication(String title) {
super(title);
setSize(300, 100);
addWindowListener(new WindowAdapter () {
public void windowClosing(WindowEvent e) {
System.exit(0);
}}
);
show();
}
}