Font list


Display a sample of all fonts available to Java in 16 point bold.

Work Location

Perform all work for this magercise in VisualAge project MageLang Magercises, package magercises.fonts.

If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name.

Tasks

Perform the following tasks:

  1. In init get and record the current list of fonts. See Toolkit.

  2. Define method paint so that it loops through the fonts, setting the current font and drawing
    fontList[i] + " 16 point Bold"
    
    in the current font. You will have to get the font height with getFontMetrics(f) where f is a Font so that you can avoid drawing the strings on top of each other.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.