Rendering Odds and Ends
Both the JTree and JTable classes make use of cell renderers to display cells and cell editors to modify
cell values. The following classes round out the utilities available for
rendering information.
The CellRendererPane Class
This utility class was built to keep renderers from
propagating repaint( ) and validate( ) calls to the components using
renderer components such as JTree
and JList. If you played around
with creating your own renderers for any of the Swing components that
use them, you’ll recall that you did not use this class yourself.
Normally this pane is wrapped around the renderer and the various
paintComponent( ) methods below are
used to do the actual drawing. Developers do not normally need to
worry about this class.
The Renderer Interface
The Swing package includes a Renderer interface (which does not appear to be used within
Swing itself) with the following methods:
- public Component getComponent( )
Return a
Componentyou can use with something like theSwingUtilities.paintComponent( )method to draw the value on the screen.- public void setValue(Object aValue, boolean isSelected)
This method can initialize the rendering component to reflect the state of the object
aValue.
This interface could be useful if you were to create a library of renderers for use with your own applications; however, it is not implemented anywhere in the Swing package as of SDK 1.4.1.
The GrayFilter Class
The GrayFilter class is an extension of the java.awt.image.RGBImageFilter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access