所有类


java.awt
类 GraphicsDevice

java.lang.Object
  继承者 java.awt.GraphicsDevice

public abstract class GraphicsDevice
   
   
   
   
   
extends Object

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 intTYPE_IMAGE_BUFFER
          设备为图像缓冲区。
static intTYPE_PRINTER
          设备为打印机。
static intTYPE_RASTER_SCREEN
          设备为光栅屏幕。
 
构造方法摘要
protected GraphicsDevice()
          这是一个无法直接实例化的抽象类。
 
方法摘要
 intgetAvailableAcceleratedMemory()
          此方法返回此设备上加速内存中可用的字节数。
 GraphicsConfigurationgetBestConfiguration(GraphicsConfigTemplate gct)
          返回通过了 GraphicsConfigTemplate 中定义的标准的可能“最佳”配置。
abstract  GraphicsConfiguration[]getConfigurations()
          返回与此 GraphicsDevice 相关的所有 GraphicsConfiguration 对象。
abstract  GraphicsConfigurationgetDefaultConfiguration()
          返回与此 GraphicsDevice 相关的默认 GraphicsConfiguration
 DisplayModegetDisplayMode()
          返回此 GraphicsDevice 的当前显示模式。
 DisplayMode[]getDisplayModes()
          返回此 GraphicsDevice 可用的所有显示模式。
 WindowgetFullScreenWindow()
          如果设备处于全屏模式,则返回表示全屏窗口的 Window 对象。
abstract  StringgetIDstring()
          返回与此 GraphicsDevice 相关的标识字符串。
abstract  intgetType()
          返回此 GraphicsDevice 的类型。
 booleanisDisplayChangeSupported()
          如果此 GraphicsDevice 支持低层显示更改,则返回 true
 booleanisFullScreenSupported()
          如果此 GraphicsDevice 支持全屏独占模式,则返回 true
 voidsetDisplayMode(DisplayMode dm)
          设置此图形设备的显示模式。
 voidsetFullScreenWindow(Window w)
          进入全屏模式,或返回窗口化模式。
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

TYPE_RASTER_SCREEN

public static final int TYPE_RASTER_SCREEN
设备为光栅屏幕。

另请参见:
常量字段值

TYPE_PRINTER

public static final int TYPE_PRINTER
设备为打印机。

另请参见:
常量字段值

TYPE_IMAGE_BUFFER

public static final int TYPE_IMAGE_BUFFER
设备为图像缓冲区。此缓冲区可驻留在设备或系统内存中,但用户无法实际看到它。

另请参见:
常量字段值
构造方法详细信息

GraphicsDevice

protected GraphicsDevice()
这是一个无法直接实例化的抽象类。必须从合适的工厂或查询方法中获取实例。

另请参见:
GraphicsEnvironment.getScreenDevices(), GraphicsEnvironment.getDefaultScreenDevice(), GraphicsConfiguration.getDevice()
方法详细信息

getType

public abstract int getType()
返回此 GraphicsDevice 的类型。

返回:
GraphicsDevice 的类型,可以是 TYPE_RASTER_SCREEN、TYPE_PRINTER 或 TYPE_IMAGE_BUFFER。
另请参见:
TYPE_RASTER_SCREEN, TYPE_PRINTER, TYPE_IMAGE_BUFFER

getIDstring

public abstract String getIDstring()
返回与此 GraphicsDevice 相关的标识字符串。

GraphicsEnvironment 中,某个特殊程序可能使用多个 GraphicsDevice。此方法返回一个标识本地 GraphicsEnvironment 中的特殊 GraphicsDeviceString。尽管没有设置此 String 的公共方法,但程序员可以在调试时使用此 String。JavaTM 运行时环境供应商可以格式化 String 的返回值。要确定如何解释 String 值,请与您的 Java 运行时供应商联系。要查找谁是供应商,可以从程序中使用“java.vendor”调用 System 类的 getProperty 方法。

返回:
一个作为此 GraphicsDevice 标识的 String

getConfigurations

public abstract GraphicsConfiguration[] getConfigurations()
返回与此 GraphicsDevice 相关的所有 GraphicsConfiguration 对象。

返回:
一个与此 GraphicsDevice 相关的 GraphicsConfiguration 对象的数组。

getDefaultConfiguration

public abstract GraphicsConfiguration getDefaultConfiguration()
返回与此 GraphicsDevice 相关的默认 GraphicsConfiguration

返回:
GraphicsDevice 的默认 GraphicsConfiguration

getBestConfiguration

public GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate gct)
返回通过了 GraphicsConfigTemplate 中定义的标准的可能“最佳”配置。

参数:
gct - 用于获取有效 GraphicsConfigurationGraphicsConfigTemplate 对象
返回:
一个通过了指定 GraphicsConfigTemplate 中定义的标准的 GraphicsConfiguration
另请参见:
GraphicsConfigTemplate