Example usage for java.awt GraphicsDevice getType

List of usage examples for java.awt GraphicsDevice getType

Introduction

In this page you can find the example usage for java.awt GraphicsDevice getType.

Prototype

public abstract int getType();

Source Link

Document

Returns the type of this GraphicsDevice .

Usage

From source file:Main.java

/**
 * Returns the GraphicsConfiguration for a point.
 *//*  w ww .  j ava2  s .  c om*/
public static GraphicsConfiguration getGraphicsConfiguration(Component aComp, int anX, int aY) {
    // Get initial GC from component (if available) and point on screen
    GraphicsConfiguration gc = aComp != null ? aComp.getGraphicsConfiguration() : null;
    Point spoint = getScreenLocation(aComp, anX, aY);

    // Replace with alternate GraphicsConfiguration if point on another screen
    for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
        if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
            GraphicsConfiguration dgc = gd.getDefaultConfiguration();
            if (dgc.getBounds().contains(spoint.x, spoint.y)) {
                gc = dgc;
                break;
            }
        }
    }

    // Return GraphicsConfiguration
    return gc;
}