Java tutorial
//package com.java2s; // Copyright 2011-2012 Paulo Augusto Peccin. See licence.txt distributed with this file. import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Window; public class Main { public static GraphicsConfiguration getGraphicsConfigurationForCurrentLocation(Window window) { GraphicsConfiguration ownedConfig = window.getGraphicsConfiguration(); Point currLocation = window.getLocation(); // Shortcut for "owned" case if (ownedConfig.getBounds().contains(currLocation)) return ownedConfig; // Search for the right screen GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); for (GraphicsDevice screen : screens) for (GraphicsConfiguration config : screen.getConfigurations()) if (config.getBounds().contains(currLocation)) return config; // If none found, lets return the "owned" one return ownedConfig; } }