import java.awt.*;
public class FontImage extends Canvas{
public void paint(Graphics g){
String fontList[];
int i;
int startY;
// Get a list of all available fonts
fontList = getToolkit().getFontList();
startY = 15;
for (i=0; i < fontList.length; i++){
// Set the font to the PLAIN version
g.setFont(new Font(fontList[i], Font.PLAIN, 12));
// Draw an example
g.drawString("This is the "+fontList[i]+" font.", 5, startY);
// Move down a little on the screen
startY += 15;
// Set the font to the BOLD version
g.setFont(new Font(fontList[i], Font.BOLD, 12));
// Draw an example
g.drawString("This is the bold "+fontList[i]+" font.", 5, startY);
// Move down a little on the screen
startY += 15;
// Set the font to the ITALIC version
g.setFont(new Font(fontList[i], Font.ITALIC, 12));
// Draw an example
g.drawString("This is the italic "+fontList[i]+" font.", 5, startY);
// Move down a little on the screen with some extra spacing
startY += 20;
}
}
}