- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JLabel
-
- javax.swing.table.DefaultTableCellRenderer
-
- 实现的所有接口
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
,TableCellRenderer
public class DefaultTableCellRenderer extends JLabel implements TableCellRenderer, Serializable
用于在JTable
呈现(显示)单个单元格的标准类。Implementation Note:此类继承自
JLabel
,这是一个标准组件类。 但是,JTable
使用独特的机制来渲染其单元格,因此需要从其单元格渲染器中稍微修改一些行为。 表类定义单个单元格渲染器,并将其用作橡皮图章,用于渲染表格中的所有单元格; 它渲染第一个单元格,更改该单元格渲染器的内容,将原点移动到新位置,重新绘制它,依此类推。 标准JLabel
组件未设计为以这种方式使用,我们希望避免每次绘制单元格时触发revalidate
。 这将大大降低性能,因为revalidate
消息将在容器的层次结构中向上传递,以确定是否会影响任何其他组件。 由于渲染器仅在绘制操作的生命周期中具有父级,因此我们同样希望避免与绘制操作的层次结构相关联的开销。 所以这个类覆盖了validate
,invalidate
,revalidate
,repaint
和firePropertyChange
方法是无操作和覆盖isOpaque
方法只是为了提高性能。 如果您编写自己的渲染器,请记住此性能考虑因素。警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans
软件包中添加了对所有JavaBeansjava.beans
长期存储的支持。 请参阅XMLEncoder
。- 另请参见:
-
JTable
, Serialized Form
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 static class
DefaultTableCellRenderer.UIResource
DefaultTableCellRenderer
的子类,实现UIResource
。-
嵌套类/接口声明在类 javax.swing.JLabel
JLabel.AccessibleJLabel
-
嵌套类/接口声明在类 javax.swing.JComponent
JComponent.AccessibleJComponent
-
嵌套类/接口声明在类 java.awt.Container
Container.AccessibleAWTContainer
-
-
字段汇总
字段 变量和类型 字段 描述 protected static Border
noFocusBorder
没有焦点的边框。-
声明的属性在类 javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
声明的属性在类 java.awt.Component
accessibleContext, 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
-
Fields declared in interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
-
构造方法摘要
构造方法 构造器 描述 DefaultTableCellRenderer()
创建默认表格单元格渲染器。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 void
firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
由于性能原因而被覆盖。protected void
firePropertyChange(String propertyName, Object oldValue, Object newValue)
由于性能原因而被覆盖。Component
getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
返回默认的表格单元格渲染器。void
invalidate()
由于性能原因而被覆盖。boolean
isOpaque()
由于性能原因而被覆盖。void
repaint()
由于性能原因而被覆盖。void
repaint(long tm, int x, int y, int width, int height)
由于性能原因而被覆盖。void
repaint(Rectangle r)
由于性能原因而被覆盖。void
revalidate()
由于性能原因而被覆盖。void
setBackground(Color c)
覆盖JComponent.setBackground
以将未选定的背景颜色指定为指定的颜色。void
setForeground(Color c)
覆盖JComponent.setForeground
以将未选定的前景色指定为指定的颜色。protected void
setValue(Object value)
将要渲染的单元格的String
对象设置为value
。void
updateUI()
来自UIManager
通知表示外观[L&F]已更改。void
validate()
由于性能原因而被覆盖。-
声明方法的类 javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition
-
声明方法的类 javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
声明方法的类 java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTree
-
声明方法的类 java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
字段详细信息
-
noFocusBorder
protected static Border noFocusBorder
没有焦点的边框。
-
-
方法详细信息
-
setForeground
public void setForeground(Color c)
覆盖JComponent.setForeground
以将未选定的前景色指定为指定的颜色。- 重写:
-
setForeground
,类JComponent
- 参数
-
c
- 将前景色设置为此值 - 另请参见:
-
Component.getForeground()
-
setBackground
public void setBackground(Color c)
覆盖JComponent.setBackground
以将未选定的背景颜色指定为指定的颜色。- 重写:
-
setBackground
类JComponent
- 参数
-
c
- 将背景颜色设置为此值 - 另请参见:
-
Component.getBackground()
,JComponent.setOpaque(boolean)
-
updateUI
public void updateUI()
来自UIManager
通知表明外观[L&F]已经改变。 使用UIManager
的最新版本替换当前UI对象。- 重写:
-
updateUI
课程JLabel
- 另请参见:
-
JComponent.updateUI()
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
返回默认的表格单元格渲染器。在打印操作期间,将使用
isSelected
和hasFocus
值false
调用此方法,以防止选择和焦点出现在打印输出中。 要根据是否正在打印表格进行其他自定义,请检查JComponent.isPaintingForPrint()
的返回值。- Specified by:
-
getTableCellRendererComponent
接口TableCellRenderer
- 参数
-
table
-JTable
-
value
- 要分配给单元格的值[row, column]
-
isSelected
- 如果选择了单元格,则为true -
hasFocus
- 如果单元格具有焦点,hasFocus
true -
row
- 要呈现的单元格的行 -
column
- 要呈现的单元格的列 - 结果
- 默认表格单元格渲染器
- 另请参见:
-
JComponent.isPaintingForPrint()
-
isOpaque
public boolean isOpaque()
由于性能原因而被覆盖。 有关更多信息,请参见Implementation Note 。- 重写:
-
isOpaque
,类JComponent
- 结果
- 如果此组件完全不透明,则为true
- 另请参见:
-
JComponent.setOpaque(boolean)
-
invalidate
public void invalidate()
由于性能原因而被覆盖。 有关更多信息,请参阅Implementation Note 。- 重写:
-
invalidate
课程Container
- 从以下版本开始:
- 1.5
- 另请参见:
-
Container.validate()
,Container.layout()
,LayoutManager2
-
validate
public void validate()
由于性能原因而被覆盖。 有关更多信息,请参阅Implementation Note 。
-
revalidate
public void revalidate()
由于性能原因而被覆盖。 有关更多信息,请参见Implementation Note 。
-
repaint
public void repaint(long tm, int x, int y, int width, int height)
由于性能原因而被覆盖。 有关更多信息,请参见Implementation Note 。- 重写:
-
repaint
课程JComponent
- 参数
-
tm
- 未使用此参数 -
x
- 脏区域的x值 -
y
- 脏区域的y值 -
width
- 脏区域的宽度 -
height
- 脏区的高度 - 另请参见:
-
JComponent.isPaintingOrigin()
,Component.isShowing()
,RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
-
repaint
public void repaint(Rectangle r)
由于性能原因而被覆盖。 有关更多信息,请参阅Implementation Note 。- 重写:
-
repaint
课程JComponent
- 参数
-
r
- 包含脏区的Rectangle
- 另请参见:
-
JComponent.isPaintingOrigin()
,Component.isShowing()
,RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
-
repaint
public void repaint()
由于性能原因而被覆盖。 有关更多信息,请参见Implementation Note 。- 重写:
-
repaint
,类Component
- 从以下版本开始:
- 1.5
- 另请参见:
-
Component.update(Graphics)
-
firePropertyChange
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
由于性能原因而被覆盖。 有关更多信息,请参阅Implementation Note 。- 重写:
-
firePropertyChange
,类Component
- 参数
-
propertyName
- 其值已更改的属性 -
oldValue
- 该物业以前的值 -
newValue
- 该物业的新值
-
firePropertyChange
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
由于性能原因而被覆盖。 有关更多信息,请参见Implementation Note 。- 重写:
-
firePropertyChange
,类JComponent
- 参数
-
propertyName
- 其值已更改的属性 -
oldValue
- 该物业以前的值 -
newValue
- 该物业的新值
-
setValue
protected void setValue(Object value)
将要渲染的单元格的String
对象设置为value
。- 参数
-
value
- 此单元格的字符串值; 如果值为null
,则将文本值设置为空字符串 - 另请参见:
-
JLabel.setText(java.lang.String)
-
-