November 2004
Intermediate to advanced
1024 pages
27h 50m
English
Here are some of the methods in the Graphics class to draw shapes:
drawLine drawRectangle drawRoundRect draw3DRect drawPolygon drawPolyline drawOval drawArc
There are also corresponding fill methods. These methods have been in the Graphics class ever since JDK 1.0. The Java 2D API uses a completely different, object-oriented approach. Instead of methods, there are classes:
Line2D Rectangle2D RoundRectangle2D Ellipse2D Arc2D QuadCurve2D CubicCurve2D GeneralPath
These classes all implement the Shape interface.
Finally, the Point2D class describes a point with an x- and a y-coordinate. Points are useful to define shapes, but they aren't themselves shapes.
To draw a shape, you first create an object of a class that implements the Shape ...
Read now
Unlock full access