HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 97 The java.awt.Font and FontMetrics Classes

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * See also color IMAGE

Graphicsinstance.setFont(particularFont) will set the current Font in the instance Graphicsinstance of graphics class to the value particularFont of class Font. There are several other such Font related methods in the Graphics class
The class Font has an important constructor used as in
Font particularFont = new Font("TimesRoman",Font.PLAIN,36);
where one can use Courier Helvetica etc. instead of Time Roman
Font.PLAIN, Font.BOLD, Font.ITALIC are possible text styles
FontMetrics fm = getFontMetrics(particularFont); // allows one to find out about the font
fm.stringWidth("text"); // returns pixel width of string "text"
fm.getHeight(); // returns total height of one line of Font



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Feb 18 1997