Working with Geometry
Trail: 2D Graphics

Lesson: Working with Geometry

In prior lessons, you have learned the graphics concept, including basic information about the coordinate system and graphic object creation. Now, you will progress to more detailed lessons about the 2D graphics classes. This lesson shows you how to use the Graphics2D class to draw graphic primitives as well as arbitrary shapes, and how to display graphics with fancy outline and fill styles. These topics are discussed in the following sections.

Drawing Geometric Primitives

This section explains how to create standard shapes such as points, lines, curves, arcs, rectangles, and ellipses.

Drawing Arbitrary Shapes

This section explains how to draw shapes represented by combinations of straight geometric primitives by using the GeneralPath class.

Filling and Stroking

This section explains how to set the stroke and paint attributes to control the outline and fill styles applied to Shape objects and text.


Problems with the examples? Try Compiling and Running the Examples: FAQs.
Complaints? Compliments? Suggestions? Give us your feedback.

Previous page: Previous Lesson
Next page: Drawing Geometric Primitives