Java Reference
In-Depth Information
import java.awt.EventQueue;
import java.awt.GraphicsEnvironment;
class EnumFontFamilyNames
{
public static void main(String[] args)
{
Runnable r = new Runnable()
{
@Override
public void run()
{
enumerate();
}
};
EventQueue.invokeLater(r);
}
static void enumerate()
{
GraphicsEnvironment ge;
ge
=
GraphicsEnviron-
ment.getLocalGraphicsEnvironment();
String[] ffns = ge.getAvailableFontFamilyNames();
for (String ffn: ffns)
System.out.println(ffn);
}
}
Anapplicationmightneedtoenumeratefontfamilynamesandpresentthislisttothe
user.Forexample,acustomfontchooserdialogboxwouldprobablylettheuserchoose
a font based on a list of font family names, styles, and sizes.
GraphicsEnvironment also declares a GraphicsDevice[]
getScreenDevices() method that returns an array of GraphicsDevice in-
stances. Each instance describes an image buffer, printer, or raster screen (a screen of
pixels) that's available to the application. (Because image buffers and printers are not
screens,itwouldhavebeenlessconfusingtohavenamedthismethod getGraphic-
sDevices() .)
Search WWH ::




Custom Search