Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds;
Insets screenInsets;
GraphicsConfiguration gc = null;
// Try to find GraphicsConfiguration, that includes the component top left corner.
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
for(int i = 0; i < gd.length; i++) {
if(gd[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration dgc = gd[i].getDefaultConfiguration();
if(dgc.getBounds().contains(p)) {
gc = dgc;