Convert to Graphics2D

With the help of a swing, he is given the transformation

paint (Graphics g) { Graphics2D g2d = (Graphics2D) g; ...... } 

will always work? Or can there be different graphic implementations, and not just Graphics2D?

+4
source share
1 answer

Short answer: yes, it should work if you are not using any other JVM. I cannot remember since when exactly, but the Paint Swings engine will always use an instance of Graphics2D to execute its layout.

+3
source

All Articles