Editing and Rendering Utilities

Both the JTree and JTable classes make use of cell renderers to display cells and cell editors to modify cell values. The CellEditor interface is the basis for these editors, and the DefaultCellEditor class provides a good implementation of this interface. Unless you’re doing something exotic, you should be able to base your cell editors on the DefaultCellEditor class.

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 paintComponent() methods below are used to do the actual drawing. Developers will not normally need to worry about this class.

Property

The CellRendererPane has only one property containing its accessible context, shown in Table 27.5.

Table 27-5. CellRendererPane Property

Property

Data Type

get

is

set

bound

Default Value

                                 accessibleContext

AccessibleContext

•

   

CellRendererPane.AccessibleCellRendererPane()

Field

protected AccessibleContext accessibleContext

This field supports the accessibleContext property.

Constructor

This class has only one constructor.

public CellRendererPane()

This constructor creates a new renderer pane that has a null layout and is not initially ...

Get Java Swing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.