java.awt.Graphics class (see GUI Graphicsis the basis for
drawing simple graphics (lines, circles, text, ...).
It is easy to use, and can be used with the
Color class to set the drawing color and
Font class to set the font for drawing text.
In Java 2, there have been many improvements in the graphics
capabilities, including the
Graphics2D class, classes to represent shapes,
easier and more powerful image processing, ....
Advanced imaging and 3-D are also being added to Java.
To draw, subclass JPanel, and write a
method for it. Call
repaint() from outside the
paintComponent method whenever something
has changed and the panel has to be redrawn.
repaint from within
paintComponent method or your programs will crash with
infinite recursion or produce some pathological flickering.