Help: Font list


Help is available for each task, or you can go straight to the solution source code.

Task 1

In init get and record the current list of fonts. See Toolkit.
Use getDefaultToolkit to get the current tool kit and then use getFontList to get the list of fonts as a String array.

Task 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.
You must create a font with
new Font(fontList[i], Font.BOLD, 16);
and then set the font of the graphics context with setFont.

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