Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Graphics or Graphics2D?

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?

like image 663
Humphrey Avatar asked Jun 10 '11 14:06

Humphrey


1 Answers

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.

like image 163
Ted Hopp Avatar answered Sep 18 '22 14:09

Ted Hopp