Java Font.getName()
Syntax
Font.getName() has the following syntax.
public String getName()
Example
In the following code shows how to use Font.getName() method.
import java.awt.Font;
import java.awt.GraphicsEnvironment;
//from w w w . ja v a 2 s. c om
public class Main {
public static void main(String[] args) throws Exception {
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int i = 0; i < fonts.length; i++) {
System.out.print(fonts[i].getFontName() + " : ");
System.out.print(fonts[i].getFamily() + " : ");
System.out.print(fonts[i].getName());
System.out.println();
}
}
}
Home »
Java Tutorial »
java.awt »
Java Tutorial »
java.awt »