Creating a Font Object

Creating a Font object can be very simple or complex, depending on the granularity with which you want to define the font. The following code fragment illustrates one of the simple approaches to Font object creation:

Font font = new Font(“Times New Roman”, 26);

This example uses a Font object constructor that requires only two items of information: the font name and size. When creating a Font object, you can also specify the font’s family, its type, its weight, its orientation, and whether or not the font is boldfaced, italicized, underlined, or strikeout. However, once you’ve created a Font object, you cannot modify the object’s attributes.