Exemplo n.º 1
0
  public GraphicsDevice getGraphicsDeviceAt(Point pos) {

    GraphicsDevice device = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice lstGDs[] = ge.getScreenDevices();
    ArrayList<GraphicsDevice> lstDevices = new ArrayList<>(lstGDs.length);

    for (GraphicsDevice gd : lstGDs) {
      GraphicsConfiguration gc = gd.getDefaultConfiguration();
      Rectangle screenBounds = gc.getBounds();
      if (screenBounds.contains(pos)) {
        lstDevices.add(gd);
      }
    }

    if (lstDevices.size() == 1) {
      device = lstDevices.get(0);
    }
    return device;
  }
Exemplo n.º 2
0
  public Rectangle getScreenViewableBounds(GraphicsDevice gd) {

    Rectangle bounds = new Rectangle(0, 0, 0, 0);

    if (gd != null) {
      GraphicsConfiguration gc = gd.getDefaultConfiguration();
      bounds = gc.getBounds();
      Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

      bounds.x += insets.left;
      bounds.y += insets.top;
      bounds.width -= (insets.left + insets.right);
      bounds.height -= (insets.top + insets.bottom);
    }
    return bounds;
  }