- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.CellRendererPane
-
- 实现的所有接口
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class CellRendererPane extends Container implements Accessible
此类插入单元格渲染器和使用它们的组件之间。 它只是为了阻止repaint()和invalidate()方法,否则这些方法会在配置渲染器时向上传播。 它由JTable,JTree和JList的实现使用。 例如,下面是如何在代码中使用CellRendererPane绘制JList中的每一行:cellRendererPane = new CellRendererPane(); ... Component rendererComponent = renderer.getListCellRendererComponent(); renderer.configureListCellRenderer(dataModel.getElementAt(row), row); cellRendererPane.paintComponent(g, rendererComponent, this, x, y, w, h);
渲染器组件必须覆盖isShowing()并无条件地返回true才能正常工作,因为Swing paint对isShowing为false的组件不执行任何操作。
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans
软件包中添加了对所有JavaBeansjava.beans
长期存储的支持。 请参阅XMLEncoder
。- 从以下版本开始:
- 1.2
- 另请参见:
- Serialized Form
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 protected class
CellRendererPane.AccessibleCellRendererPane
此类实现CellRendererPane
类的可访问性支持。-
嵌套类/接口声明在类 java.awt.Container
Container.AccessibleAWTContainer
-
-
字段汇总
字段 变量和类型 字段 描述 protected AccessibleContext
accessibleContext
AccessibleContext
与此相关CellRendererPan
-
声明的属性在类 java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
构造方法摘要
构造方法 构造器 描述 CellRendererPane()
构造一个CellRendererPane对象。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 protected void
addImpl(Component x, Object constraints, int index)
如果指定的组件已经是这个的子组件,那么我们不会做任何事情 - 堆栈顺序对于单元格渲染器组件无关紧要(CellRendererPane无论如何都不会绘制)。AccessibleContext
getAccessibleContext()
获取与此CellRendererPane关联的AccessibleContext。void
invalidate()
重写以避免在配置单元格渲染器子项时向树上传播无效。void
paint(Graphics g)
不应该叫。void
paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
调用this.paintComponent(g,c,p,x,y,w,h,false)。void
paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate)
在图形对象g上绘制单元格渲染器组件c。void
paintComponent(Graphics g, Component c, Container p, Rectangle r)
使用矩形x,y,width,height字段调用this.paintComponent()。void
update(Graphics g)
不应该叫。-
声明方法的类 java.awt.Container
add, 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, validateTree
-
声明方法的类 java.awt.Component
action, 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
-
-
-
-
字段详细信息
-
accessibleContext
protected AccessibleContext accessibleContext
AccessibleContext
与这CellRendererPan
相关联
-
-
方法详细信息
-
invalidate
public void invalidate()
重写以避免在配置单元格渲染器子项时向树上传播无效。- 重写:
-
invalidate
在类Container
- 另请参见:
-
Container.validate()
,Container.layout()
,LayoutManager2
-
paint
public void paint(Graphics g)
不应该叫。- 重写:
-
paint
在类Container
- 参数
-
g
- 指定的图形窗口 - 另请参见:
-
Component.update(Graphics)
-
update
public void update(Graphics g)
不应该叫。- 重写:
-
update
在类Container
- 参数
-
g
- 指定的图形窗口 - 另请参见:
-
Component.update(Graphics)
-
addImpl
protected void addImpl(Component x, Object constraints, int index)
如果指定的组件已经是这个的子组件,那么我们不会做任何事情 - 堆栈顺序对于单元格渲染器组件无关紧要(CellRendererPane无论如何都不会绘制)。- 重写:
-
addImpl
在类Container
- 参数
-
x
- 要添加的组件 -
constraints
- 表示此组件的布局约束的对象 -
index
- 容器列表中插入组件的位置,其中-1
表示追加到末尾 - 另请参见:
-
Container.add(Component)
,Container.add(Component, int)
,Container.add(Component, java.lang.Object)
,Container.invalidate()
,LayoutManager
,LayoutManager2
-
paintComponent
public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate)
在图形对象g上绘制单元格渲染器组件c。 在绘制组件之前,它被重新定义(如果有必要),它的边界被设置为w,h,图形对象被(有效地)转换为x,y。 如果它是JComponent,则暂时关闭双缓冲。 绘制组件后,它的边界将重置为-w,-h,0,0,这样,如果它是绘制的最后一个渲染器组件,它将不会开始消耗输入。 Container p是我们实际使用的组件,通常它等于this.getParent()。 如果shouldValidate为true,则组件c将在绘制之前进行验证。- 参数
-
g
- 要绘制的Graphics
对象 -
c
- 绘制Component
-
p
- 实际绘制的Container
组件 -
x
- 指定区域左侧的int,以像素为单位,从图形上下文的左边缘开始测量 -
y
- 指定要绘制的区域顶部的int,以图形上下文的上边缘向下测量的像素为单位 -
w
- 一个int,指定绘制区域的宽度,以像素为单位 -
h
- 一个int,指定绘制区域的高度,以像素为单位 -
shouldValidate
- 如果为true,则在绘制之前将验证组件c
-
paintComponent
public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h)
调用this.paintComponent(g,c,p,x,y,w,h,false)。- 参数
-
g
- 要绘制的Graphics
对象 -
c
- 要绘制的Component
-
p
- 实际绘制的Container
组件 -
x
- 指定区域左侧的int,以像素为单位,从图形上下文的左边缘开始测量 -
y
- 一个int,指定要绘制的区域的顶部,以图形上下文的上边缘向下测量的像素为单位 -
w
- 一个int,指定绘制区域的宽度,以像素为单位 -
h
- 指定绘制区域高度的int,以像素为单位
-
paintComponent
public void paintComponent(Graphics g, Component c, Container p, Rectangle r)
使用矩形x,y,width,height字段调用this.paintComponent()。- 参数
-
g
- 要绘制的Graphics
对象 -
c
- 绘制Component
-
p
- 实际绘制的Container
组件 -
r
- 绘制Rectangle
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
获取与此CellRendererPane关联的AccessibleContext。 对于CellRendererPanes,AccessibleContext采用AccessibleCellRendererPane的形式。 如有必要,将创建一个新的AccessibleCellRendererPane实例。- Specified by:
-
getAccessibleContext
接口Accessible
- 重写:
-
getAccessibleContext
在类Component
- 结果
- 一个AccessibleCellRendererPane,用作此CellRendererPane的AccessibleContext
-
-