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
Point2D class describes a point with an x and a y coordinate. Points are used to define shapes, but they aren’t themselves shapes.
To draw a shape, first create an object of a class that implements the
Shape interface ...