The basic rendering mechanism is the same as in previous
versions of the JDK--the drawing system controls when and how programs can draw.
When a component needs to be displayed, its paint
or update
method is automatically invoked with an appropriate Graphics
context.
The Java 2D API introduces java.awt.Graphics2D
,
a new type of Graphics
object. Graphics2D
extends
the Graphics
class to provide access to the enhanced graphics and rendering features of the
Java 2D API.
To use Java 2D API features, you cast the Graphics
object passed
into a
component's rendering method to a Graphics2D
object.
public void Paint (Graphics g) { Graphics2D g2 = (Graphics2D) g; ... }