Create BufferedImage from component - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Create

Description

Create BufferedImage from component

Demo Code


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*/
  }
}

Related Tutorials