import java.awt.AWTException; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.Insets; import java.awt.Rectangle; import java.awt.Robot; import java.awt.image.BufferedImage; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JRootPane; public class SimpleTransFrame1 extends JFrame { private Robot robot; private BufferedImage image; public SimpleTransFrame1() { super(); } public SimpleTransFrame1(String title) { super(title); init(); } public SimpleTransFrame1(GraphicsConfiguration gc) { super(gc); init(); } public SimpleTransFrame1(String title, GraphicsConfiguration gc) { super(title, gc); init(); } private void init() { try { robot = new Robot(); } catch (AWTException ex) { ex.printStackTrace(); return; } Rectangle bounds = new Rectangle(100, 100, 400, 400); image = robot.createScreenCapture(bounds); setBounds(bounds); setRootPane(new ImageRootPane()); JComponent content = (JComponent)getContentPane(); content.setOpaque(false); } class ImageRootPane extends JRootPane { public void paintComponent(Graphics g) { Insets insets = SimpleTransFrame1.this.getInsets(); g.drawImage(image, -insets.left, -insets.top, this); } } public static void main(String[] args) { JFrame frame = new SimpleTransFrame1("Capture Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(new JButton("Button")); frame.setVisible(true); } }