Java Reference
In-Depth Information
Assumingthat ge referencesa GraphicsEnvironment instance,executethefol-
lowing line to obtain this array:
GraphicsDevice[] gd = ge.getScreenDevices();
Youcanfindoutwhatkindofgraphicsdeviceisrepresentedbyaparticular Graph-
icsDevice instance, by calling GraphicsDevice 's int getType() method
and comparing the result to one of GraphicsDevice 's TYPE_IMAGE_BUFFER ,
TYPE_PRINTER , and TYPE_RASTER_SCREEN constants.
Note You can access the default graphics device by invoking GraphicsEn-
vironment 's GraphicsDevice getDefaultScreenDevice() method. If
there'sonlyonesupporteddevice, getDefaultScreenDevice() isequivalentto
getScreenDevices()[0] .
getScreenDevices() throws java.awt.HeadlessException when
called on a headless platform (a platform that doesn't support a keyboard, mouse,
or monitor). For example, the platform may be part of a server farm (see ht-
tp://en.wikipedia.org/wiki/Server_farm ) . If you're concerned about
this possibility, you can have your application first call GraphicsEnvironment 's
boolean isHeadless() class method, which returns true when the platform is
headless.
Onceyouhaveagraphicsdevice,youcanobtainallsupported configurations (color
models, bounds [origin and extents in device coordinates], and so on) by calling
GraphicsDevice 's GraphicsConfiguration[] getConfigurations()
method.
Assumingthat gd referencesa GraphicsDevice instance,executethefollowing
line to obtain this array:
GraphicsConfiguration[] gc = gd.getConfigurations();
Afteryouhavea GraphicsConfiguration instance,youcanlearnaboutitscol-
or model by invoking ColorModel getColorModel() , its bounds by invoking
Rectangle getBounds() , and so on.
Note You can access the default configuration by invoking GraphicsDevice 's
GraphicsConfiguration getDefaultConfiguration() method. If
there'sonlyonesupportedconfiguration, getDefaultConfiguration() isequi-
valent to getConfigurations()[0] .
Search WWH ::




Custom Search