Java Reference
In-Depth Information
Table 8-4 UIManager Methods
METHOD NAME
PURPOSE
EXAMPLE
get()
Returns an object
Object fileIcon =
from the defaults
UIManager.get("DirectoryPane.fileIcon");
table
getLookAndFeel()
Returns the current
UIManager.getLookAndFeel().getClass().getName();
default Look and
Feel or null
put()
Stores an object in
UIManager.put("Label.font",new
the defaults table
Font(“SansSerif”,Font.ITALIC,10));
setLookAndFeel()
Sets the current UIManager.setLookAndFeel
default Look and Feel ("javax.swing.plaf.metal.MetalLookAndFeel");
using a LookAndFeel
object
Creating a Window
Figure 8-7 displays the initial stub of code in the BillPayer program. Recall
that stubbing is the process of creating just enough code to compile and run the
program, but not enough code to make the program fully functional. In line 15,
the BillPayer class extends JFrame. Recall that a Java program may extend, or
build on, a superclass provided either by Java or by classes you create. By extend-
ing JFrame, BillPayer will be a subclass, or working copy, of the JFrame class. The
BillPayer class will behave identically to the original class and have all the fields
and methods declared in or inherited from the JFrame class. Also, the BillPayer
class implements ActionListener; as you learned earlier, this enables the program
to listen for mouse clicks from the user.
1 /*
2 Chapter 8 BillPayer Power & Light
3 Programmer: Joy Starks
4 Date: November 19, 2007
5 Program Name: BillPayer
6 */
7
8 import java.io.*;
9 import java.awt.*;
10 import java.awt.event.*;
11 import javax.swing.*;
12 import java.text.*;
13 import java.util.*;
14
15 public class BillPayer extends JFrame implements ActionListener
16 {
FIGURE 8-7
 
Search WWH ::




Custom Search