import javax.swing.*;
import java.awt.*;
public class JFontListJavaExample extends JFrame
{
public void paint(Graphics gr)
{
setTitle("Finding Font List In System");
super.paint(gr);
int i, x, y = 60;
final int VERT_SPACE = 20;
final int HORIZ_SPACE = 160;
GraphicsEnvironment GE =GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fntnms = GE.getAvailableFontFamilyNames();
for(i = 0; i<fntnms.length; i += 5)
{
x = 10;
gr.setFont(new Font("Arial", Font.PLAIN, 10));
gr.drawString(fntnms[i], x, y);
if(i+1 < fntnms.length)
gr.drawString(fntnms[i + 1], x += HORIZ_SPACE, y);
if(i+2 < fntnms.length)
gr.drawString(fntnms[i + 2], x += HORIZ_SPACE, y);
if(i+3 < fntnms.length)
gr.drawString(fntnms[i + 3], x += HORIZ_SPACE, y);
if(i+4 < fntnms.length)
gr.drawString(fntnms[i + 4], x += HORIZ_SPACE, y);
y = y + VERT_SPACE;
}
}
public static void main(String[] as)
{
JFontListJavaExample frm = new JFontListJavaExample();
frm.setSize(820, 620);
frm.setVisible(true);
}
}