O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

More on Drawing and Filling Shapes

The Graphics class provides methods for rendering the following:

  • Lines

  • PolyLines

  • Rectangles

  • Arcs

  • Ovals

  • Polygons

  • Text

  • Images

Rectangles, arcs, ovals, and polygons can also be filled. In this section, we will explore all but the last item listed above—for information on displaying and filtering images, the Loading and Displaying Images chapter and the Image Filtering chapter.

Drawing Lines

Lines are drawn by use of invoking Graphics.drawLine(int x, int y, int x2, int y2). The AWT is not capable of drawing lines of variable thickness; the graphics's pen, and therefore the lines it draws, are always one pixel thick. In addition, lines are always drawn solid—there is no provision for patterned lines such as dotted or dashed. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required