[ Contact ] [ Links ] [ Previous : 20 / 29 : Overview of the Java 2D API ] [ Up ] [ Next : 22 / 29 : Java 2D Rendering Context ]

Java 2D Rendering

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;
    ...
}

 

 

 


See the "Links" link above to find out the sources of the proposed informations
Pascal Vuylsteker / eScience / Computer Science / ANU
Last modified: 20/4/2004
TOC - Print
Send your comments at :
<Hugh.Fisher@anu.edu.au>