Using the 2D API

From its earliest days, Java has included a nice graphics class called java.awt.Graphics. To graphics professionals, however, Graphics left some features to be desired. More mature GUI platforms, such as Windows 95 and above and the Macintosh, support features that are not present in Graphics.

Now, in Java 2, all that has changed. Sun has provided a much richer, two-dimensional graphics class called java.awt.Graphics2D. This section describes the major improvements available in Graphics2D. Listing 38.9 shows a demonstration program, PathsFill.java, that shows how to display shapes by using Graphics2D. The PathsFill class is a type of canvas, so Graphics2D is able to draw on it by casting the Graphics parameter to paint() as ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.