|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.awt.GraphicsDevice
public abstract class GraphicsDevice
GraphicsDevice 类描述了可以在特殊图形环境中使用的图形设备。这些设备包括屏幕和打印机设备。注意,在 GraphicsEnvironment 实例中可以有许多屏幕和许多打印机。每个图形设备都有一个或多个与之相关的 GraphicsConfiguration 对象。这些对象指定了可以使用 GraphicsDevice 的不同配置。
在多屏幕环境中,GraphicsConfiguration 对象可用于在多屏幕上呈现组件。以下代码示例演示了如何在 GraphicsEnvironment 中针对每个屏幕设备的每个 GraphicsConfiguration 创建 JFrame 对象。
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();
}
}
GraphicsEnvironment,
GraphicsConfiguration| 字段摘要 | |
|---|---|
static int |
TYPE_IMAGE_BUFFER
设备为图像缓冲区。 |
static int |
TYPE_PRINTER
设备为打印机。 |
static int |
TYPE_RASTER_SCREEN
设备为光栅屏幕。 |
| 构造方法摘要 | |
|---|---|
protected |
GraphicsDevice()
这是一个无法直接实例化的抽象类。 |
| 方法摘要 | |
|---|---|
int |
getAvailableAcceleratedMemory()
此方法返回此设备上加速内存中可用的字节数。 |
GraphicsConfiguration |
getBestConfiguration(GraphicsConfigTemplate gct)
返回通过了 GraphicsConfigTemplate 中定义的标准的可能“最佳”配置。 |
abstract GraphicsConfiguration[] |
getConfigurations()
返回与此 GraphicsDevice 相关的所有 GraphicsConfiguration 对象。 |
abstract GraphicsConfiguration |
getDefaultConfiguration()
返回与此 GraphicsDevice 相关的默认 GraphicsConfiguration。 |
DisplayMode |
getDisplayMode()
返回此 GraphicsDevice 的当前显示模式。 |
DisplayMode[] |
getDisplayModes()
返回此 GraphicsDevice 可用的所有显示模式。 |
Window |
getFullScreenWindow()
如果设备处于全屏模式,则返回表示全屏窗口的 Window 对象。 |
abstract String |
getIDstring()
返回与此 GraphicsDevice 相关的标识字符串。 |
abstract int |
getType()
返回此 GraphicsDevice 的类型。 |
boolean |
isDisplayChangeSupported()
如果此 GraphicsDevice 支持低层显示更改,则返回 true。 |
boolean |
isFullScreenSupported()
如果此 GraphicsDevice 支持全屏独占模式,则返回 true。 |
void |
setDisplayMode(DisplayMode dm)
设置此图形设备的显示模式。 |
void |
setFullScreenWindow(Window w)
进入全屏模式,或返回窗口化模式。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final int TYPE_RASTER_SCREEN
public static final int TYPE_PRINTER
public static final int TYPE_IMAGE_BUFFER
| 构造方法详细信息 |
|---|
protected GraphicsDevice()
GraphicsEnvironment.getScreenDevices(),
GraphicsEnvironment.getDefaultScreenDevice(),
GraphicsConfiguration.getDevice()| 方法详细信息 |
|---|
public abstract int getType()
GraphicsDevice 的类型。
GraphicsDevice 的类型,可以是 TYPE_RASTER_SCREEN、TYPE_PRINTER 或 TYPE_IMAGE_BUFFER。TYPE_RASTER_SCREEN,
TYPE_PRINTER,
TYPE_IMAGE_BUFFERpublic abstract String getIDstring()
GraphicsDevice 相关的标识字符串。
在 GraphicsEnvironment 中,某个特殊程序可能使用多个 GraphicsDevice。此方法返回一个标识本地 GraphicsEnvironment 中的特殊 GraphicsDevice 的 String。尽管没有设置此 String 的公共方法,但程序员可以在调试时使用此 String。JavaTM 运行时环境供应商可以格式化 String 的返回值。要确定如何解释 String 值,请与您的 Java 运行时供应商联系。要查找谁是供应商,可以从程序中使用“java.vendor”调用 System 类的 getProperty 方法。
GraphicsDevice 标识的 String。public abstract GraphicsConfiguration[] getConfigurations()
GraphicsDevice 相关的所有 GraphicsConfiguration 对象。
GraphicsDevice 相关的 GraphicsConfiguration 对象的数组。public abstract GraphicsConfiguration getDefaultConfiguration()
GraphicsDevice 相关的默认 GraphicsConfiguration。
GraphicsDevice 的默认 GraphicsConfiguration。public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct)
GraphicsConfigTemplate 中定义的标准的可能“最佳”配置。
gct - 用于获取有效 GraphicsConfiguration 的 GraphicsConfigTemplate 对象
GraphicsConfigTemplate 中定义的标准的 GraphicsConfiguration。GraphicsConfigTemplatepublic boolean isFullScreenSupported()
GraphicsDevice 支持全屏独占模式,则返回 true。
public void setFullScreenWindow(Window w)
如果 isFullScreenSupported 返回 true,则全屏模式被视为独占,这意味着:
Component.enableInputMethods(false),使组件成为无客户机的输入方法框架。
如果 isFullScreenSupported 返回 false,则通过将窗口大小调整为屏幕大小、定位在 (0,0) 来模拟全屏独占模式。
当进入全屏独占模式时,如果看不到作为全屏窗口使用的窗口,此方法将会使其可见。当返回到窗口化模式时,窗口仍将保持可见。
当从独占全屏窗口模式返回到窗口化模式时,任何调用 setDisplayMode 做出的显示更改都将自动恢复到它的原始状态。
w - 一个用作全屏窗口的窗口;如果返回到窗口化模式,则为 null。一些平台希望全屏窗口成为顶层组件(例如,Frame);因此这里最好使用 Frame,而不用 Window。isFullScreenSupported(),
getFullScreenWindow(),
setDisplayMode(java.awt.DisplayMode),
Component.enableInputMethods(boolean),
Component.setVisible(boolean)public Window getFullScreenWindow()
Window 对象。
null。setFullScreenWindow(Window)public boolean isDisplayChangeSupported()
GraphicsDevice 支持低层显示更改,则返回 true。
setDisplayMode(java.awt.DisplayMode)public void setDisplayMode(DisplayMode dm)
dm - 此图形设备的新显示模式
IllegalArgumentException - 如果提供的 DisplayMode 为 null,或者在 getDisplayModes 返回的数组中不可用
UnsupportedOperationException - 如果 isDisplayChangeSupported 返回 falsegetDisplayMode(),
getDisplayModes(),
isDisplayChangeSupported()public DisplayMode getDisplayMode()
GraphicsDevice 的当前显示模式。
setDisplayMode(DisplayMode)public DisplayMode[] getDisplayModes()
GraphicsDevice 可用的所有显示模式。
public int getAvailableAcceleratedMemory()
ImageCapabilities 对象,还有更多的查询方法,可用于确定是否在加速内存中创建一个特殊的 VolatileImage。
VolatileImage.flush(),
ImageCapabilities.isAccelerated()
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。