所有类
javax.swing
类 CellRendererPane
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 的实现中。例如,以下是绘制 JList 中每个行的代码中使用 CellRendererPane 的方式:
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(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans
包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder
。
方法摘要 |
protected void |
addImpl(Component x, Object constraints, int index) 如果指定组件已经是此组件的子组件,则不必再操心去做任何事,堆栈顺序对于单元格渲染器组件而言无关紧要(CellRendererPane 不管怎样都不进行绘制)。 |
AccessibleContext |
getAccessibleContext() 获取与此 CellRendererPane 相关的 AccessibleContext。 |
void |
invalidate() 重写此方法是为了避免配置单元格渲染器的子级时顺着树向上传播 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, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, 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, 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, getPeer, 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, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
accessibleContext
protected AccessibleContext accessibleContext
CellRendererPane
public CellRendererPane()
-
构造一个 CellRendererPane 对象。
invalidate
public void invalidate()
-
重写此方法是为了避免配置单元格渲染器的子级时顺着树向上传播 invalidate。
-
-
覆盖:
-
类
Container
中的 invalidate
-
-
另请参见:
-
Container.validate()
, Container.layout()
, LayoutManager
paint
public void paint(Graphics g)
-
不应调用。
-
-
覆盖:
-
类
Container
中的 paint
-
-
参数:
-
g
- 指定的 Graphics 窗口
-
另请参见:
-
Component.update(Graphics)
update
public void update(Graphics g)
-
不应调用。
-
-
覆盖:
-
类
Container
中的 update
-
-
参数:
-
g
- 指定的 Graphics 窗口
-
另请参见:
-
Component.update(Graphics)
addImpl
protected void addImpl(Component x,
Object constraints,
int index)
-
如果指定组件已经是此组件的子组件,则不必再操心去做任何事,堆栈顺序对于单元格渲染器组件而言无关紧要(CellRendererPane 不管怎样都不进行绘制)。
-
-
覆盖:
-
类
Container
中的 addImpl
-
-
参数:
-
x
- 要添加的组件
-
constraints
- 表示此组件的布局限制的对象
-
另请参见:
-
Container.add(Component)
, Container.add(Component, int)
, Container.add(Component, java.lang.Object)
, LayoutManager
, LayoutManager2
paintComponent
public void paintComponent(Graphics g,
Component c,
Container p,
int x,
int y,
int w,
int h,
boolean shouldValidate)
-
在图形对象 g 上绘制一个单元格渲染器组件 c。在绘制该组件之前,要对此方法进行 reparent 操作(如有必要),将其边界设置为 w,h 并且将图形对象(有效地)转换成 x,y。如果该对象是一个 JComponent,则暂时关闭双重缓冲。在绘制组件之后,将边界重新设置为 -w, -h, 0, 0。因此,如果该组件是最后一个被绘制的渲染器组件,那么它不会开始使用输入。Container p 是我们实际要绘制的组件,通常它等于 this.getParent()。如果 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)。
-
-
paintComponent
public void paintComponent(Graphics g,
Component c,
Container p,
Rectangle r)
-
使用矩形的 x、y、width 和 height 字段的调用 this.paintComponent()。
-
-