Java AWT Font available font families via GraphicsEnvironment class

Introduction

The following code shows how to obtain the names of the available font families:

import java.awt.GraphicsEnvironment;

public class Main {
   public static void main(String[] args) {

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      String[] FontList = ge.getAvailableFontFamilyNames();
      for (int i = 0; i < FontList.length; i++)
         System.out.println(FontList[i]);

   }/*ww w .j  a v a 2s  . c  om*/
}



PreviousNext

Related