The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: 2D Graphics
Lesson: Displaying Graphics with Graphics2D

Controlling Rendering Quality

You can use the Graphics2D rendering hints attribute to specify whether you want objects to be rendered as quickly as possible or whether you prefer that the rendering quality be as high as possible.

To set or change the rendering hints attribute in the Graphics2D context, you can construct a RenderingHints object and pass it into Graphics2D setRenderingHints. If you just want to set one hint, you can call Graphics2D setRenderingHint and specify the key-value pair for the hint you want to set. (The key-value pairs are defined in the RenderingHints class.)

For example, to set a preference for antialiasing to be used if possible, you could use setRenderingHint:

g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,aliasing);

Note:  Not all platforms support modification of the rendering mode, so specifying rendering hints does not guarantee that they will be used.

RenderingHints supports the following types of hints:

When a hint is set to default, the platform rendering default is used is used.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.