Java Reference
In-Depth Information
There is no simple way to change the properties of the current font, such as making
it italic. Every change in a font normally requires that you define a new Font object
and use it as an argument to setFont .
Display 18.23 gives some useful details about constructors, methods, and constants
that are members of, or are related to, the class Font .
The drawString Method
The drawString method writes the text given by the String at the point ( X , Y ) of the
Graphics_Object . The text is written in the current font, color, and font size.
SYNTAX
Graphics_Object .drawString( String , X , Y );
EXAMPLE
g.drawString("I love you madly.", X_START, Y_START);
Display 18.23 Some Methods and Constants for the Class Font (part 1 of 2)
The class Font is in the java.awt package.
CONSTRUCTOR FOR THE CLASS Font
public Font(String fontName, int styleModifications, int size)
Constructor that creates a version of the font named by fontName with the specified
styleModifications and size .
CONSTANTS IN THE CLASS Font
Font.BOLD
Specifies bold style.
Font.ITALIC
Specifies italic style.
Font.PLAIN
Specifies plain style—that is, not bold and not italic.
NAMES OF FONTS (These three are guaranteed by Java.
Your system will probably have others as well as these.)
"Monospaced"
See Display 18.22 for a sample.
"SansSerif"
See Display 18.22 for a sample.
Search WWH ::




Custom Search