Creating a buffered image using Component.createImage().
//use only if the component is visible on the screen. //It returns buffered images that do not support transparent pixels. import java.awt.image.BufferedImage; import javax.swing.JFrame; public class Main { public static void main(String[] argv) throws Exception { JFrame f = new JFrame(); f.setVisible(true); int width = 300; int height = 500; BufferedImage bimage = (BufferedImage) f.createImage(width, height); if (bimage == null) { System.out.println("component is not visible on the screen"); } } }