Java Reference
In-Depth Information
the screen, this effectively allows you to do a screen dump of the inside of a window (or any
JComponent ).
Component comp = ...
RepaintManager manager = RepaintManager.currentManager(null);
Image htmlImage = manager.getOffscreenBuffer(comp, comp.getWidth(),
comp.getHeight());
// or
Image volatileImage = manager.getVolatileOffscreenBuffer(comp, comp.getWidth(),
comp.getHeight());
Table 4-1 shows the two properties of RepaintManager . They allow you to disable double
buffering for all drawing operations of a component (hierarchy) and to set the maximum
double buffer size, which defaults to the end user's screen size.
Table 4-1. RepaintManager Properties
Property Name
Data Type
Access
doubleBufferingEnabled
boolean
Read-write
doubleBufferMaximumSize
Dimension
Read-write
Tip To globally disable double-buffered drawing, call RepaintManager.currentManager(aComponent).
setDoubleBufferingEnabled(false) .
Although it's rarely done, providing your own RepaintManager subclass does allow you to
customize the mechanism of painting dirty regions of the screen, or at least track when the
painting is finished. Overriding any of the following four methods allows you to customize the
mechanisms:
public synchronized void addDirtyRegion(JComponent component, int x, int y,
int width, int height)
public Rectangle getDirtyRegion(JComponent component)
public void markCompletelyClean(JComponent component)
public void markCompletelyDirty(JComponent component)
UIDefaults Class
The UIDefaults class represents a lookup table containing the display settings installed for the
current look and feel, such as which font to use within a JList , as well as what color or icon
should be displayed within a JTree node. The use of UIDefaults will be detailed in Chapter 20
with the coverage of Java's pluggable look and feel architecture. Here, you will get a brief intro-
duction to the UIDefaults table.
 
Search WWH ::




Custom Search