Question

I am new to Java and have been trying to make some simple games in it with lots of images on screen. Since then I have been using the 'Graphics' class to draw these images, strings and shapes, but I recently came across Graphics2D which seems to be the same sort of thing..

Could anyone tell me what the difference is between them and which one would be the best to use? Would I have to perform some large updates for my code if I wanted to use Graphics2D?

Was it helpful?

Solution

The Graphics that is passed to paint(Graphics) is actually a Graphics2D object. If you want to use any of the Graphics2D functionality, just cast it and make the calls you need.

OTHER TIPS

Graphics2D is newer and plugs into the newer Java 2D api set. Use Graphics2D unless you have to be backwards compatible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top