cellRendererPane = new CellRendererPane(); ... Component rendererComponent = renderer.getListCellRendererComponent(); renderer.configureListCellRenderer(dataModel.getElementAt(row), row); cellRendererPane.paintComponent(g, rendererComponent, this, x, y, w, h);
A renderer component must override isShowing() and unconditionally return true to work correctly because the Swing paint does nothing for components with isShowing false.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Class and Description |
|---|---|
| protected class | CellRendererPane.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| protected AccessibleContext | accessibleContext
Hides java. AccessibleContext associated with this CellRendererPan
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addImpl(Component x, Object constraints, int index)
Overrides java. If the specified component is already a child of this then we don't bother doing anything - stacking order doesn't matter for cell renderer components (CellRendererPane doesn't paint anyway). |
| public AccessibleContext | Returns: an AccessibleCellRendererPane that serves as the AccessibleContext of this CellRendererPaneOverrides java. Implements javax. Gets the AccessibleContext associated with this CellRendererPane. |
| public void | invalidate()
Overrides java. Overridden to avoid propagating a invalidate up the tree when the cell renderer child is configured. |
| public void | |
| public void | paintComponent(Graphics
the g, Component Graphics object to draw onthe c, Container Component to drawthe p, int Container component actually drawn onan int specifying the left side of the area draw in, in pixels,
measured from the left edge of the graphics context x, int an int specifying the top of the area to draw in, in pixels
measured down from the top edge of the graphics context y, int an int specifying the width of the area draw in, in pixels w, int an int specifying the height of the area draw in, in pixels h, boolean if true, component shouldValidate)c will be validated
before being paintedPaint a cell renderer component c on graphics object g. |
| public void | paintComponent(Graphics
the g, Component Graphics object to draw onthe c, Container Component to drawthe p, int Container component actually drawn onan int specifying the left side of the area draw in, in pixels,
measured from the left edge of the graphics context x, int an int specifying the top of the area to draw in, in pixels
measured down from the top edge of the graphics context y, int an int specifying the width of the area draw in, in pixels w, int an int specifying the height of the area draw in, in pixels h)Calls this.paintComponent(g, c, p, x, y, w, h, false). |
| public void | paintComponent(Graphics
the g, Component Graphics object to draw onthe c, Container Component to drawthe p, Rectangle Container component actually drawn onthe r)Rectangle to draw inCalls this.paintComponent(g, c, p, r.x, r.y, r.width, r.height) where
|
| public void | |
| private void | writeObject(ObjectOutputStream s)
Hides java. Serializes this |
| accessibleContext | back to summary |
|---|---|
| protected AccessibleContext accessibleContext Hides java.
| |
| CellRendererPane | back to summary |
|---|---|
| public CellRendererPane() Construct a CellRendererPane object. | |
| addImpl | back to summary |
|---|---|
| protected void addImpl(Component x, Object constraints, int index) Overrides java. If the specified component is already a child of this then we don't bother doing anything - stacking order doesn't matter for cell renderer components (CellRendererPane doesn't paint anyway). | |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this CellRendererPane. For CellRendererPanes, the AccessibleContext takes the form of an AccessibleCellRendererPane. A new AccessibleCellRendererPane instance is created if necessary.
| |
| invalidate | back to summary |
|---|---|
| public void invalidate() Overrides java. Overridden to avoid propagating a invalidate up the tree when the cell renderer child is configured. | |
| paint | back to summary |
|---|---|
| public void paint(Graphics g) Overrides java. Shouldn't be called. | |
| paintComponent | back to summary |
|---|---|
| public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) Paint a cell renderer component c on graphics object g. Before the component is drawn it's reparented to this (if that's necessary), it's bounds are set to w,h and the graphics object is (effectively) translated to x,y. If it's a JComponent, double buffering is temporarily turned off. After the component is painted it's bounds are reset to -w, -h, 0, 0 so that, if it's the last renderer component painted, it will not start consuming input. The Container p is the component we're actually drawing on, typically it's equal to this.getParent(). If shouldValidate is true the component c will be validated before painted.
| |
| paintComponent | back to summary |
|---|---|
| public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h) Calls this.paintComponent(g, c, p, x, y, w, h, false).
| |
| paintComponent | back to summary |
|---|---|
| public void paintComponent(Graphics g, Component c, Container p, Rectangle r) Calls this.paintComponent(g, c, p, r.x, r.y, r.width, r.height) where
| |
| update | back to summary |
|---|---|
| public void update(Graphics g) Overrides java. Shouldn't be called. | |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides java. Doc from java. Serializes this
| |
CellRendererPane class.
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides java. Get the role of this object. |
| AccessibleCellRendererPane | back to summary |
|---|---|
| protected AccessibleCellRendererPane() Constructs an | |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides java. Get the role of this object.
| |