Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
60
Chapter 2 First Servlets
CloseableFrame
CloseableFrame
is an extension of the standard
Frame
class, with the addi
tion that user requests to quit the frame are honored. This is the top level
window on which
WebClient
is built.
Listing 2.16 CloseableFrame.java
import java.awt.*;
import java.awt.event.*;
/** A Frame that you can actually quit. Used as
* the starting point for most Java 1.1 graphical
* applications.
*/
public class CloseableFrame extends Frame {
public CloseableFrame(String title) {
super(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
/** Since we are doing something permanent, we need
* to call super.processWindowEvent first.
*/
public void processWindowEvent(WindowEvent event) {
super.processWindowEvent(event); // Handle listeners
if (event.getID() == WindowEvent.WINDOW_CLOSING)
System.exit(0);
}
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved