java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.CellRendererPane
- All Implemented Interfaces:
- ImageObserver,- MenuContainer,- Serializable,- 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
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classThis class implements accessibility support for theCellRendererPaneclass.Nested classes/interfaces declared in class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces declared in class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AccessibleContextAccessibleContextassociated with thisCellRendererPanFields declared in class java.awt.ComponentBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields declared in interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidIf 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).Gets the AccessibleContext associated with this CellRendererPane.voidOverridden to avoid propagating a invalidate up the tree when the cell renderer child is configured.voidShouldn't be called.voidpaintComponent(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).voidpaintComponent(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.voidpaintComponent(Graphics g, Component c, Container p, Rectangle r) Calls this.paintComponent(g, c, p, r.x, r.y, r.width, r.height) whereris the inputRectangleparameter.voidShouldn't be called.Methods declared in class java.awt.Containeradd, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, validate, validateTreeMethods declared in class java.awt.Componentaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
- 
Field Details- 
accessibleContextAccessibleContextassociated with thisCellRendererPan
 
- 
- 
Constructor Details- 
CellRendererPanepublic CellRendererPane()Construct a CellRendererPane object.
 
- 
- 
Method Details- 
invalidatepublic void invalidate()Overridden to avoid propagating a invalidate up the tree when the cell renderer child is configured.- Overrides:
- invalidatein class- Container
- See Also:
 
- 
paintShouldn't be called.
- 
updateShouldn't be called.
- 
addImplIf 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).
- 
paintComponentpublic 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- Graphicsobject to draw on
- c- the- Componentto draw
- p- the- Containercomponent 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- cwill be validated before being painted
 
- 
paintComponentCalls this.paintComponent(g, c, p, x, y, w, h, false).- Parameters:
- g- the- Graphicsobject to draw on
- c- the- Componentto draw
- p- the- Containercomponent 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
 
- 
paintComponentCalls this.paintComponent(g, c, p, r.x, r.y, r.width, r.height) whereris the inputRectangleparameter.- Parameters:
- g- the- Graphicsobject to draw on
- c- the- Componentto draw
- p- the- Containercomponent actually drawn on
- r- the- Rectangleto draw in
 
- 
getAccessibleContextGets 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:
- getAccessibleContextin interface- Accessible
- Overrides:
- getAccessibleContextin class- Component
- Returns:
- an AccessibleCellRendererPane that serves as the AccessibleContext of this CellRendererPane
 
 
-