GraphicsDevice class describes the graphics devices
that might be available in a particular graphics environment. These
include screen and printer devices. Note that there can be many screens
and many printers in an instance of GraphicsEnvironment. Each
graphics device has one or more GraphicsConfiguration objects
associated with it. These objects specify the different configurations
in which the GraphicsDevice can be used.
In a multi-screen environment, the GraphicsConfiguration
objects can be used to render components on multiple screens. The
following code sample demonstrates how to create a JFrame
object for each GraphicsConfiguration on each screen
device in the GraphicsEnvironment:
GraphicsEnvironment ge = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
for (int j = 0; j < gs.length; j++) {
GraphicsDevice gd = gs[j];
GraphicsConfiguration[] gc =
gd.getConfigurations();
for (int i=0; i < gc.length; i++) {
JFrame f = new
JFrame(gs[j].getDefaultConfiguration());
Canvas c = new Canvas(gc[i]);
Rectangle gcBounds = gc[i].getBounds();
int xoffs = gcBounds.x;
int yoffs = gcBounds.y;
f.getContentPane().add(c);
f.setLocation((i*50)+xoffs, (i*60)+yoffs);
f.show();
}
}
For more information on full-screen exclusive mode API, see the Full-Screen Exclusive Mode API Tutorial.
GraphicsEnvironment, GraphicsConfiguration
| Modifier and Type | Class and Description |
|---|---|
| public static enum | GraphicsDevice.
Kinds of translucency supported by the underlying system. |
| Modifier and Type | Field and Description |
|---|---|
| private volatile Window | |
| public static final int | TYPE_IMAGE_BUFFER
Device is an image buffer. |
| public static final int | TYPE_PRINTER
Device is a printer. |
| public static final int | TYPE_RASTER_SCREEN
Device is a raster screen. |
| private Rectangle |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: number of bytes available in accelerated memory. A negative return value indicates that the amount of accelerated memory on this GraphicsDevice is indeterminate.This method returns the number of bytes available in accelerated memory on this device. |
| public GraphicsConfiguration | Returns: aGraphicsConfiguration that passes
the criteria defined in the specified
GraphicsConfigTemplate.the gct)GraphicsConfigTemplate object
used to obtain a valid GraphicsConfigurationReturns the "best" configuration possible that passes the
criteria defined in the |
| public abstract GraphicsConfiguration[] | Returns: an array ofGraphicsConfiguration
objects that are associated with this
GraphicsDevice.Returns all of the |
| public abstract GraphicsConfiguration | Returns: the defaultGraphicsConfiguration
of this GraphicsDevice.Returns the default |
| public DisplayMode | Returns: the current display mode of this graphics device.Returns the current display mode of this
|
| public DisplayMode[] | Returns: all of the display modes available for this graphics device.Returns all display modes available for this
|
| public Window | Returns: the full-screen window, ornull if the device is
not in full-screen mode.Returns the |
| public abstract String | Returns: aString that is the identification
of this GraphicsDevice.Returns the identification string associated with this
|
| pack-priv GraphicsConfiguration | |
| public abstract int | Returns: the type of thisGraphicsDevice, which can
either be TYPE_RASTER_SCREEN, TYPE_PRINTER or TYPE_IMAGE_BUFFER.Returns the type of this |
| public boolean | Returns: whether low-level display changes are supported for this graphics device.Returns |
| public boolean | Returns: whether full-screen exclusive mode is available for this graphics deviceReturns |
| pack-priv static boolean | isWindowOpacitySupported()
Returns whether the windowing system supports changing the opacity value of top-level windows. |
| pack-priv boolean | |
| pack-priv static boolean | isWindowShapingSupported()
Returns whether the windowing system supports changing the shape of top-level windows. |
| public boolean | Returns: whether the given translucency kind is supporteda kind of translucency support translucencyKindReturns whether the given level of translucency is supported by this graphics device. |
| public void | setDisplayMode(DisplayMode
The new display mode of this graphics device. dm)Sets the display mode of this graphics device. |
| public void | setFullScreenWindow(Window
a window to use as the full-screen window; w)null
if returning to windowed mode. Some platforms expect the
fullscreen window to be a top-level component (i.e., a Frame);
therefore it is preferable to use a Frame here rather than a
Window.Enter full-screen mode, or return to windowed mode. |
| fullScreenWindow | back to summary |
|---|---|
| private volatile Window fullScreenWindow | |
| TYPE_IMAGE_BUFFER | back to summary |
|---|---|
| public static final int TYPE_IMAGE_BUFFER Device is an image buffer. This buffer can reside in device or system memory but it is not physically viewable by the user. | |
| TYPE_PRINTER | back to summary |
|---|---|
| public static final int TYPE_PRINTER Device is a printer. | |
| TYPE_RASTER_SCREEN | back to summary |
|---|---|
| public static final int TYPE_RASTER_SCREEN Device is a raster screen. | |
| windowedModeBounds | back to summary |
|---|---|
| private Rectangle windowedModeBounds | |
| GraphicsDevice | back to summary |
|---|---|
| protected GraphicsDevice() This is an abstract class that cannot be instantiated directly. Instances must be obtained from a suitable factory or query method. | |
| getAvailableAcceleratedMemory | back to summary |
|---|---|
| public int getAvailableAcceleratedMemory() This method returns the number of bytes available in
accelerated memory on this device.
Some images are created or cached
in accelerated memory on a first-come,
first-served basis. On some operating systems,
this memory is a finite resource. Calling this method
and scheduling the creation and flushing of images carefully may
enable applications to make the most efficient use of
that finite resource.
| |
| getBestConfiguration | back to summary |
|---|---|
| public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct) Returns the "best" configuration possible that passes the
criteria defined in the
| |
| getConfigurations | back to summary |
|---|---|
| public abstract GraphicsConfiguration[] getConfigurations() Returns all of the
| |
| getDefaultConfiguration | back to summary |
|---|---|
| public abstract GraphicsConfiguration getDefaultConfiguration() Returns the default
| |
| getDisplayMode | back to summary |
|---|---|
| public DisplayMode getDisplayMode() Returns the current display mode of this
| |
| getDisplayModes | back to summary |
|---|---|
| public DisplayMode[] getDisplayModes() Returns all display modes available for this
| |
| getFullScreenWindow | back to summary |
|---|---|
| public Window getFullScreenWindow() Returns the
| |
| getIDstring | back to summary |
|---|---|
| public abstract String getIDstring() Returns the identification string associated with this
A particular program might use more than one
| |
| getTranslucencyCapableGC | back to summary |
|---|---|
| pack-priv GraphicsConfiguration getTranslucencyCapableGC() | |
| getType | back to summary |
|---|---|
| public abstract int getType() Returns the type of this
| |
| isDisplayChangeSupported | back to summary |
|---|---|
| public boolean isDisplayChangeSupported() Returns
| |
| isFullScreenSupported | back to summary |
|---|---|
| public boolean isFullScreenSupported() Returns
| |
| isWindowOpacitySupported | back to summary |
|---|---|
| pack-priv static boolean isWindowOpacitySupported() Returns whether the windowing system supports changing the opacity value of top-level windows. Note that this method may sometimes return true, but the native windowing system may still not support the concept of translucency (due to the bugs in the windowing system). | |
| isWindowPerpixelTranslucencySupported | back to summary |
|---|---|
| pack-priv boolean isWindowPerpixelTranslucencySupported() | |
| isWindowShapingSupported | back to summary |
|---|---|
| pack-priv static boolean isWindowShapingSupported() Returns whether the windowing system supports changing the shape of top-level windows. Note that this method may sometimes return true, but the native windowing system may still not support the concept of shaping (due to the bugs in the windowing system). | |
| isWindowTranslucencySupported | back to summary |
|---|---|
| public boolean isWindowTranslucencySupported(GraphicsDevice. Returns whether the given level of translucency is supported by this graphics device.
| |
| setDisplayMode | back to summary |
|---|---|
| public void setDisplayMode(DisplayMode dm) Sets the display mode of this graphics device. This is only allowed
if
The display mode must be one of the display modes returned by
Example code:
| |
| setFullScreenWindow | back to summary |
|---|---|
| public void setFullScreenWindow(Window w) Enter full-screen mode, or return to windowed mode. The entered
full-screen mode may be either exclusive or simulated. Exclusive
mode is only available if Exclusive mode implies:
The simulated full-screen mode places and resizes the window to the maximum
possible visible area of the screen. However, the native windowing system
may modify the requested geometry-related data, so that the When entering full-screen mode, if the window to be used as a full-screen window is not visible, this method will make it visible. It will remain visible when returning to windowed mode.
When entering full-screen mode, all the translucency effects are reset for
the window. Its shape is set to
It is unspecified and platform-dependent how decorated windows operate
in full-screen mode. For this reason, it is recommended to turn off
the decorations in a
When returning to windowed mode from an exclusive full-screen window,
any display changes made by calling
| |
isWindowTranslucencySupported
| Modifier and Type | Field and Description |
|---|---|
| public static final GraphicsDevice. | PERPIXEL_TRANSLUCENT
Represents support in the underlying system for windows that contain or might contain pixels with arbitrary alpha values between and including 0.0 and 1.0. |
| public static final GraphicsDevice. | PERPIXEL_TRANSPARENT
Represents support in the underlying system for windows each pixel of which is guaranteed to be either completely opaque, with an alpha value of 1.0, or completely transparent, with an alpha value of 0.0. |
| public static final GraphicsDevice. | TRANSLUCENT
Represents support in the underlying system for windows all of the pixels of which have the same alpha value between or including 0.0 and 1.0. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static GraphicsDevice. | |
| public static GraphicsDevice. |
| PERPIXEL_TRANSLUCENT | back to summary |
|---|---|
| public static final GraphicsDevice. Represents support in the underlying system for windows that contain or might contain pixels with arbitrary alpha values between and including 0.0 and 1.0. | |
| PERPIXEL_TRANSPARENT | back to summary |
|---|---|
| public static final GraphicsDevice. Represents support in the underlying system for windows each pixel of which is guaranteed to be either completely opaque, with an alpha value of 1.0, or completely transparent, with an alpha value of 0.0. | |
| TRANSLUCENT | back to summary |
|---|---|
| public static final GraphicsDevice. Represents support in the underlying system for windows all of the pixels of which have the same alpha value between or including 0.0 and 1.0. | |
| WindowTranslucency | back to summary |
|---|---|
| private WindowTranslucency() | |
| valueOf | back to summary |
|---|---|
| public static GraphicsDevice. | |
| values | back to summary |
|---|---|
| public static GraphicsDevice. | |