Java Reference
In-Depth Information
In general, do not combine complex AWT components, such as Menus and
Panels, in the same container control as Swing components. The reason for this
is because when lightweight components, such as Swing, overlap with heavy-
weight components, such as AWT, the heavyweight component is painted on top.
Entering Code to Extend JFrame
Figure 7-7 displays the comments, the import statements, and the class
header for the Classics on DVD program. Line 14 extends the top-level container
JFrame and implements the ActionListener.
1 /*
2
Chapter 7: Classics on DVD
3
Programmer: J. Starks
4
Date:
November 12, 2007
5
Filename:
DVD.java
6
Purpose:
This program creates a Swing interface for sorting a DVD collection.
7 */
8
9 import java.awt.*;
10 import java.awt.event.*;
11 import javax.swing.*;
12 import javax.swing.text.*;
13
14 public class DVD extends JFrame implements ActionListener
15 {
FIGURE 7-7
The following step enters the code to extend JFrame in the class header, as
you begin coding the Classics on DVD program.
To Extend JFrame in the Class Header
1. Enter the code as shown in Figure 7-7, replacing the programmer name
and date shown with your name and the current date.
TextPad displays the beginning code for the DVD class (Figure 7-8). The
comments, import statements, and class header are displayed.
block
comment
import
statements
class
header
FIGURE 7-8
 
Search WWH ::




Custom Search