Java examples for 2D Graphics:BufferedImage Create
Create BufferedImage from component
import java.awt.image.BufferedImage; import javax.swing.JButton; public class Main { public void m() { JButton component = new JButton(); int width = 100, height = 100; BufferedImage bimage = (BufferedImage)component.createImage(width, height); if (bimage == null) { // The component is not visible on the screen }/* w w w .j a v a 2 s. c o m*/ } }