Class RefImage

All Implemented Interfaces:
RenderedImage, WritableRenderedImage, Transparency

public class RefImage extends BufferedImage
A BufferedImage subclass that holds a strong reference to its graphics object. This means that the graphics will never go away as long as someone holds a reference to this image, and createGraphics() and getGraphics() can be called multiple times safely, and will always return the same graphics object.
  • Constructor Details

    • RefImage

      public RefImage(int width, int height, int type)
      Creates a new instance of RefImage
      Parameters:
      width - a Integer object.
      height - a Integer object.
      type - a Integer object.
  • Method Details

    • createGraphics

      public Graphics2D createGraphics()

      Create a graphics object only if it is currently null, otherwise return the existing graphics object.

      Overrides:
      createGraphics in class BufferedImage