graphics2d « cast « Java Data Type Q&A





1. Java2D: Is it always safe to cast Graphics into Graphics2D    stackoverflow.com

Assuming we always use a Sun JVM (say, 1.5+), is it always safe to cast a Graphics reference to Graphics2D? I haven't seen it cause any problems yet and, to ...

2. graphics to graphics2d casting    java-forums.org

Hi, I'm sturagle with the graphics2D API. I dont understand the following: 1) If graphics2D is an extension of graphics why do you cast graphics to graphics2D? downcasting won't add any new atributes and methoeds to the graphics object right??? so whats the point? 2) Its seems that every exsampe regarding the graphics2D had this syntax: public void paint(Graphics g) { ...

3. Why does Graphics class need to be cast as a Graphics2D to get items shown?    forums.oracle.com

Just to clarify, why can't one just pass a Graphics2D class and take it from there, i.e. paint(Graphics2D g2){...}? It compiles fine. So the compiler is consistent in the sublcass concept. However, at run-time, the window stays white (blank) no matter if you use a Graphics method to draw a rectangle, for example, or the Graphics 2D sequences of drawing a ...