You are here:   HomeJava ProgrammingSwingAdd Components to JFrame Java Example
by Dinesh Thakur Category: Swing


import javax.swing.*;

import java.awt.*;
public class JFontListJavaExample extends JFrame
          public void paint(Graphics gr)
              setTitle("Finding Font List In System");
                  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);
 Find Font List in Java Swing Example

Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article