Java Code Examples for java.awt.Graphics2D.getDeviceConfiguration()

The following are Jave code examples for showing how to use getDeviceConfiguration() of the java.awt.Graphics2D class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: VolatileImageConfigurationTest.java   View Source Code Vote up 7 votes
private void drawBackingStoreImage(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    GraphicsConfiguration gc = g2d.getDeviceConfiguration();
    if (vImg == null ||
        vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
        /* Create a new volatile image */
        vImg = createVolatileImage(PANEL_WIDTH, PANEL_HEIGHT / 3);
    }

    Graphics vImgGraphics = vImg.createGraphics();
    vImgGraphics.setColor(Color.WHITE);
    vImgGraphics.fillRect(0, 0, PANEL_WIDTH, PANEL_HEIGHT / 3);
    drawInfo(vImgGraphics,
             PANEL_X,
             PANEL_Y,
             "Backbuffer",
             Color.MAGENTA);
    g.drawImage(vImg, 0, PANEL_Y * 2, this);
}