Java Reference
In-Depth Information
Sample Run: Figure 12-2 shows the output of the WelcomeApplet produced by the
Applet Viewer in Windows 7 Professional.
FIGURE 12-2 Output of the WelcomeApplet
You terminate the applet by clicking the close button in the upper-right corner of
the Applet Viewer, or by closing the HTML document in which the applet is
embedded.
Two ways to make your applets more attractive are to vary the type font and color. Next,
we introduce the class es Font and Color , contained in the package java.awt .
class Font
The GUI programs we have created so far have used only the default font. To show text
in different fonts when the program executes, Java provides the class Font . The class
Font is contained in the package java.awt , so you need to use the following import
statement in your program:
import java.awt.*;
The class Font contains various constructors, methods, and constants, some of which
are described in Table 12-4.
1
2
TABLE 12-4 Some Constructors and Methods of the class Font
public Font(String name, int style, int size)
//Constructor
//Creates a new Font from the specified name, style, and point
//size.
public String getFamily()
//Returns the family name of this Font.
public String getFontName()
//Returns the font face name of this Font.
 
 
Search WWH ::




Custom Search