本文整理汇总了Java中java.awt.Component.getGraphicsConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getGraphicsConfiguration方法的具体用法?Java Component.getGraphicsConfiguration怎么用?Java Component.getGraphicsConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.getGraphicsConfiguration方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import java.awt.Component; //导入方法依赖的package包/类
public void paint(Component c, Graphics g, int x, int y, int w, int h, Object[] args) {
if (w <= 0 || h <= 0) {
return;
}
Object key = getClass();
GraphicsConfiguration config = c.getGraphicsConfiguration();
Cache cache = getCache(key);
Image image = cache.getImage(key, config, w, h, args);
int attempts = 0;
do {
boolean draw = false;
if (image instanceof VolatileImage) {
switch (((VolatileImage) image).validate(config)) {
case VolatileImage.IMAGE_INCOMPATIBLE:
((VolatileImage) image).flush();
image = null;
break;
case VolatileImage.IMAGE_RESTORED:
draw = true;
break;
}
}
if (image == null) {
image = createImage(c, w, h, config);
cache.setImage(key, config, w, h, args, image);
draw = true;
}
if (draw) {
Graphics g2 = image.getGraphics();
paintToImage(c, g2, w, h, args);
g2.dispose();
}
paintImage(c, g, x, y, w, h, image, args);
} while (image instanceof VolatileImage && ((VolatileImage) image).contentsLost() && ++attempts < 3);
}
示例2: getScreenBounds
import java.awt.Component; //导入方法依赖的package包/类
/**
* Get size of screen accounting for the screen insets (i.e. Windows taskbar)
*
* @return
*/
public static Rectangle getScreenBounds(Component c) {
final Rectangle bounds =
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
final GraphicsConfiguration config = c.getGraphicsConfiguration();
final Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
bounds.translate(insets.left, insets.top);
bounds.setSize(bounds.width - insets.left - insets.right,
bounds.height - insets.top - insets.bottom);
return bounds;
}
示例3: setDestination
import java.awt.Component; //导入方法依赖的package包/类
public void setDestination(TestEnvironment env) {
Component c = env.getCanvas();
GraphicsConfiguration gc = c.getGraphicsConfiguration();
int w = env.getWidth();
int h = env.getHeight();
if (transparency == 0) {
env.setTestImage(gc.createCompatibleImage(w, h));
} else {
env.setTestImage(gc.createCompatibleImage(w, h, transparency));
}
}
示例4: ScreenResolution
import java.awt.Component; //导入方法依赖的package包/类
/**
* Constructor where the resolution is computed.
*
* @param comp - the frame of the gui - needed to get the resolution of the screen where the app is showed
*/
public ScreenResolution(Component comp) {
//set the current screen resolution
GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
示例5: SunVolatileImage
import java.awt.Component; //导入方法依赖的package包/类
public SunVolatileImage(Component comp,
int width, int height, Object context)
{
this(comp, comp.getGraphicsConfiguration(),
width, height, context, null);
}
示例6: setScreenResolution
import java.awt.Component; //导入方法依赖的package包/类
/**
* Saves the resolution of the screen where the component is showed.
*
* @param comp - the frame for which the resolution of the containing screen is needed
*/
public void setScreenResolution(Component comp) {
GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}