Hacking Swing: Translucent Windows
Subject:   Problem with multiple monitors
Date:   2006-01-03 08:25:37
From:   kennet
In the original source code for the TransparentBackground (now somewhat rewritten) the Toolkit is asked for screen dimensions. But if one is using two monitors, just one of the monitors dimensions is reported. This makes the image transparent on just one of the monitors. According to this now needs something like

public void updateBackground() {
try {
Robot rbt = new Robot();
background = rbt.createScreenCapture(getTotalScreenBounds());
} catch (Exception ex) {

private Rectangle getTotalScreenBounds(){
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
int w = 0, h = 0;
for(int i = 0; i < ge.getScreenDevices().length; i++){
w += ge.getMaximumWindowBounds().width;
h = ge.getMaximumWindowBounds().height;
return new Rectangle(0,0, w, h);

In this case I'm presuming that the two monitors are placed beside each other not ontop.

1 to 1 of 1
1 to 1 of 1