You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/SIPRPSoft/src/leaf/ui/LeafTransparentPanel.java

48 lines
1013 B

package leaf.ui;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class LeafTransparentPanel extends JPanel
{
private static final long serialVersionUID = 1L;
private BufferedImage background = null;
public LeafTransparentPanel()
{
updateBackground();
}
private void updateBackground()
{
try
{
Robot rbt = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
background = rbt.createScreenCapture( new Rectangle( 0, 0, (int) dim.getWidth(), (int) dim.getHeight() ) );
} catch( AWTException ex )
{
ex.printStackTrace();
}
}
@Override
public void paintComponent( Graphics g )
{
Point pos = this.getLocationOnScreen();
Point offset = new Point( -pos.x, -pos.y );
g.drawImage( background, offset.x, offset.y, null );
}
}