Package Summary  Overview Summary

class:CellRendererPane [CHANGED]

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CellRendererPane
extends Container
implements Accessible
This class is inserted in between cell renderers and the components that use them. It just exists to thwart the repaint() and invalidate() methods which would otherwise propagate up the tree when the renderer was configured. It's used by the implementations of JTable, JTree, and JList. For example, here's how CellRendererPane is used in the code the paints each row in a JList:
   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™JavaBeans has been added to the java.beans package. Please see XMLEncoder.

Since:
1.2
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CellRendererPane
extends Container
implements Accessible
This class is inserted in between cell renderers and the components that use them. It just exists to thwart the repaint() and invalidate() methods which would otherwise propagate up the tree when the renderer was configured. It's used by the implementations of JTable, JTree, and JList. For example, here's how CellRendererPane is used in the code the paints each row in a JList:
   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 XMLEncoder.

Since:
1.2
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CellRendererPane
extends Container
implements Accessible
This class is inserted in between cell renderers and the components that use them. It just exists to thwart the repaint() and invalidate() methods which would otherwise propagate up the tree when the renderer was configured. It's used by the implementations of JTable, JTree, and JList. For example, here's how CellRendererPane is used in the code the paints each row in a JList:
   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 XMLEncoder.

Since:
1.2

field:accessibleContext [NONE]

constructor:CellRendererPane() [NONE]

  • CellRendererPane

    public CellRendererPane()
    Construct a CellRendererPane object.

method:invalidate() [NONE]

  • invalidate

    public void invalidate()
    Overridden to avoid propagating a invalidate up the tree when the cell renderer child is configured.
    Overrides:
    invalidate in class Container
    See Also:
    Container.validate(), Container.layout(), LayoutManager2
  • method:paint(java.awt.Graphics) [NONE]

    paint

    public void paint?(Graphics g)
    Shouldn't be called.
    Overrides:
    paint in class Container
    Parameters:
    g - the specified Graphics window
    See Also:
    Component.update(Graphics)

    method:update(java.awt.Graphics) [NONE]

    update

    public void update?(Graphics g)
    Shouldn't be called.
    Overrides:
    update in class Container
    Parameters:
    g - the specified Graphics window
    See Also:
    Component.update(Graphics)

    method:addImpl(java.awt.Component,java.lang.Object,int) [NONE]

    addImpl

    protected void addImpl?(Component x, Object constraints, int index)
    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).
    Overrides:
    addImpl in class Container
    Parameters:
    x - the component to be added
    constraints - an object expressing layout constraints for this component
    index - the position in the container's list at which to insert the component, where -1 means append to the end
    See Also:
    Container.add(Component), Container.add(Component, int) , Container.add(Component, java.lang.Object) , Container.invalidate(), LayoutManager, LayoutManager2

    method:paintComponent(java.awt.Graphics,java.awt.Component,java.awt.Container,int,int,int,int,boolean) [NONE]

    paintComponent

    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.
    Parameters:
    g - the Graphics object to draw on
    c - the Component to draw
    p - the Container component actually drawn on
    x - an int specifying the left side of the area draw in, in pixels, measured from the left edge of the graphics context
    y - an int specifying the top of the area to draw in, in pixels measured down from the top edge of the graphics context
    w - an int specifying the width of the area draw in, in pixels
    h - an int specifying the height of the area draw in, in pixels
    shouldValidate - if true, component c will be validated before being painted

    method:paintComponent(java.awt.Graphics,java.awt.Component,java.awt.Container,int,int,int,int) [NONE]

    paintComponent

    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).
    Parameters:
    g - the Graphics object to draw on
    c - the Component to draw
    p - the Container component actually drawn on
    x - an int specifying the left side of the area draw in, in pixels, measured from the left edge of the graphics context
    y - an int specifying the top of the area to draw in, in pixels measured down from the top edge of the graphics context
    w - an int specifying the width of the area draw in, in pixels
    h - an int specifying the height of the area draw in, in pixels

    method:paintComponent(java.awt.Graphics,java.awt.Component,java.awt.Container,java.awt.Rectangle) [NONE]

    paintComponent

    public void paintComponent?(Graphics g, Component c, Container p, Rectangle r)
    Calls this.paintComponent() with the rectangles x,y,width,height fields.
    Parameters:
    g - the Graphics object to draw on
    c - the Component to draw
    p - the Container component actually drawn on
    r - the Rectangle to draw in

    method:getAccessibleContext() [NONE]

    getAccessibleContext

    public AccessibleContext getAccessibleContext()
    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.
    Specified by:
    getAccessibleContext in interface Accessible
    Overrides:
    getAccessibleContext in class Component
    Returns:
    an AccessibleCellRendererPane that serves as the AccessibleContext of this CellRendererPane

    © 2020 Oracle Corporation and/or its affiliates