Hi,
if I only could find where I read that for J2SE (>=1.2?) you always have a Graphics2D instance. I swear I have read it once.


The argument for is Sun's (and IBM's) doing unfortunately. Since 1.2(?)
JComponent.paint() gets passed a Graphics2D object in the majority of
cases[1] and people are writing production code such as the following
example habitually.

 public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g2.draw(new Rectangle());
 }

Worse is that publications teaching usage of Swing encourage this usage.



It's true, I never think twice before casting a Graphics to Graphics2D. This works in all places where you can get such an instance (e.g. Image.getGraphics(), certain printing related classes).

cu
Robert


_______________________________________________ Classpath mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to