/** * Finds and returns the boundaries of the screen in which <code>x/y</code> are. * @param x some x coordinate * @param y some y coordinate * @return the boundaries of the nearest screen containing <code>x/y</code> or <code>null</code> */ protected Rectangle findDevice( int x, int y ){ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); GraphicsDevice best = null; int bestDist = 0; for( GraphicsDevice device : devices ){ Rectangle bounds = device.getDefaultConfiguration().getBounds(); int dist = dist( bounds.x, bounds.width, x ) + dist( bounds.y, bounds.height, y ); if( best == null || dist < bestDist ){ best = device; bestDist = dist; } } if( best == null ){ return null; } return best.getDefaultConfiguration().getBounds(); }
/** * Finds and returns the boundaries of the screen in which <code>x/y</code> are. * @param x some x coordinate * @param y some y coordinate * @return the boundaries of the nearest screen containing <code>x/y</code> or <code>null</code> */ protected Rectangle findDevice( int x, int y ){ GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); GraphicsDevice best = null; int bestDist = 0; for( GraphicsDevice device : devices ){ Rectangle bounds = device.getDefaultConfiguration().getBounds(); int dist = dist( bounds.x, bounds.width, x ) + dist( bounds.y, bounds.height, y ); if( best == null || dist < bestDist ){ best = device; bestDist = dist; } } if( best == null ){ return null; } return best.getDefaultConfiguration().getBounds(); }