How to create a Graphics2D instance?

necromancer picture necromancer · May 14, 2013 · Viewed 18.1k times · Source

What's the easiest way in Java SE 7 to obtain an instance just to plot a few points for debugging? Desktop environment.

Answer

BLuFeNiX picture BLuFeNiX · May 14, 2013

You could use a BufferedImage:

BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics2D = image.createGraphics();