Java Platform 1.2
Beta 4

Class com.sun.java.swing.CellRendererPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--com.sun.java.swing.CellRendererPane

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 propogate 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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.

See Also:
Serialized Form

Inner Class Summary
protected   CellRendererPane.AccessibleCellRendererPane
           
 
Field Summary
protected  AccessibleContext accessibleContext
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT
 
Constructor Summary
CellRendererPane()
           
 
Method Summary
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).
 AccessibleContext getAccessibleContext()
          Get the AccessibleContext associated with this CellRendererPane
 void invalidate()
          Overridden to avoid propogating a invalidate up the tree when the cell renderer child is configured.
 void paint(Graphics g)
          Shouldn't be called.
 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.
 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).
 void paintComponent(Graphics g, Component c, Container p, Rectangle r)
          Calls this.paintComponent() with the rectangles x,y,width,height fields.
 void update(Graphics g)
          Shouldn't be called.
 
Methods inherited from class java.awt.Container
add , add , add , add , add , addContainerListener , addNotify , countComponents , deliverEvent , doLayout , findComponentAt , findComponentAt , getAlignmentX , getAlignmentY , getComponent , getComponentAt , getComponentAt , getComponentCount , getComponents , getInsets , getLayout , getMaximumSize , getMinimumSize , getPreferredSize , insets , isAncestorOf , layout , list , list , locate , minimumSize , paintComponents , paramString , preferredSize , print , printComponents , processContainerEvent , processEvent , remove , remove , removeAll , removeContainerListener , removeNotify , setLayout , validate , validateTree
 
Methods inherited from class java.awt.Component
action , add , addComponentListener , addFocusListener , addInputMethodListener , addKeyListener , addMouseListener , addMouseMotionListener , addPropertyChangeListener , addPropertyChangeListener , bounds , checkImage , checkImage , coalesceEvents , contains , contains , createImage , createImage , disable , disableEvents , dispatchEvent , enable , enable , enableEvents , enableInputMethods , firePropertyChange , getBackground , getBounds , getBounds , getColorModel , getComponentOrientation , getCursor , getDropTarget , getFont , getFontMetrics , getForeground , getGraphics , getHeight , getInputContext , getInputMethodRequests , getLocale , getLocation , getLocation , getLocationOnScreen , getName , getParent , getPeer , getSize , getSize , getToolkit , getTreeLock , getWidth , getX , getY , gotFocus , handleEvent , hasFocus , hide , imageUpdate , inside , isDisplayable , isDoubleBuffered , isEnabled , isFocusTraversable , isLightweight , isOpaque , isShowing , isValid , isVisible , keyDown , keyUp , list , list , list , location , lostFocus , mouseDown , mouseDrag , mouseEnter , mouseExit , mouseMove , mouseUp , move , nextFocus , paintAll , postEvent , prepareImage , prepareImage , printAll , processComponentEvent , processFocusEvent , processInputMethodEvent , processKeyEvent , processMouseEvent , processMouseMotionEvent , remove , removeComponentListener , removeFocusListener , removeInputMethodListener , removeKeyListener , removeMouseListener , removeMouseMotionListener , removePropertyChangeListener , removePropertyChangeListener , repaint , repaint , repaint , repaint , requestFocus , reshape , resize , resize , setBackground , setBounds , setBounds , setComponentOrientation , setCursor , setDropTarget , setEnabled , setFont , setForeground , setLocale , setLocation , setLocation , setName , setSize , setSize , setVisible , show , show , size , toString , transferFocus
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

Field Detail

accessibleContext

protected AccessibleContext accessibleContext
Constructor Detail

CellRendererPane

public CellRendererPane()
Method Detail

invalidate

public void invalidate()
Overridden to avoid propogating a invalidate up the tree when the cell renderer child is configured.
Overrides:
invalidate in class Container

paint

public void paint(Graphics g)
Shouldn't be called.
Overrides:
paint in class Container

update

public void update(Graphics g)
Shouldn't be called.
Overrides:
update in class Container

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

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 neccessary), 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

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

public void paintComponent(Graphics g,
                           Component c,
                           Container p,
                           Rectangle r)
Calls this.paintComponent() with the rectangles x,y,width,height fields.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this CellRendererPane
Specified by:
getAccessibleContext in interface Accessible
Returns:
the AccessibleContext of this CellRendererPane

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.