Java Swing Tutorial - Java GraphicsEnvironment .createGraphics (BufferedImage img)








Syntax

GraphicsEnvironment.createGraphics(BufferedImage img) has the following syntax.

public abstract Graphics2D createGraphics(BufferedImage img)

Example

In the following code shows how to use GraphicsEnvironment.createGraphics(BufferedImage img) method.

/*from w w w  .jav  a 2 s .co  m*/
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage;

public class Main {
  public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    BufferedImage bi = new BufferedImage(10, 20, 0);
    Graphics2D g2 = ge.createGraphics(bi);
    
  }
}