Display available fontsTag(s): AWT


[JDK1.1]
import java.awt.*;
public class FontList {
 public static void main(String args[]) {
  String[] fontNames = Toolkit.getDefaultToolkit().getFontList();
  int j = fontNames.length;
  for (int i = 0 ; i < j ;i++ ) {
   System.out.println(fontNames[i]);
   }
  }
}
[JDK1.2]
import java.awt.*;
public class FontList {
   public static void main(String args[]) {
     GraphicsEnvironment ge = 
         GraphicsEnvironment.getLocalGraphicsEnvironment();
     String fontNames[] = ge.getAvailableFontFamilyNames();
     int j = fontNames.length;
     for (int i = 0 ; i < j ;i++ ) {
       System.out.println(fontNames[i]);
       }
     }
}

blog comments powered by Disqus