所有类


javax.swing.table
类 DefaultTableCellRenderer

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
直接已知子类:
DefaultTableCellRenderer.UIResource

public class DefaultTableCellRenderer
   
   
   
   
extends JLabel
implements TableCellRenderer, Serializable

呈现(显示) JTable 中每个单元格的标准类。

实现注意事项:此类继承自一个标准的组件类 JLabel。但是 JTable 为其单元格的呈现使用了特殊的机制,因此要求稍微对其单元格渲染器的行为进行修改。该 table 类定义一个单元格渲染器,并将其用作呈现表中所有单元格的橡皮图章;它呈现第一个单元格、更改该单元格渲染器的内容、将原点移到新的位置、重新进行绘制,等等。标准的 JLabel 组件不是通过此方式使用的,每次绘制单元格时,我们都希望避免触发 revalidate 事件。这会大大降低程序的性能,因为 revalidate 消息会沿容器的层次结构向上传递,以确定任意其他组件是否将受到影响。由于该渲染器是绘制操作生命周期中惟一的父类,类似地,我们也希望避免与为进行绘制操作而遍历容器层次结构相关联的开销。所以此类将 validateinvalidaterevalidaterepaintfirePropertyChange 方法重写为无操作,并单独重写 isOpaque 方法以提高性能。如果您编写自己的渲染器,请记住此性能方面的考虑。

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前的序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
JTable

嵌套类摘要
static class DefaultTableCellRenderer.UIResource
          DefaultTableCellRenderer 的一个子类,它实现 UIResource
 
从类 javax.swing.JLabel 继承的嵌套类/接口
JLabel.AccessibleJLabel
 
从类 javax.swing.JComponent 继承的嵌套类/接口
JComponent.AccessibleJComponent
 
从类 java.awt.Container 继承的嵌套类/接口
Container.AccessibleAWTContainer
 
从类 java.awt.Component 继承的嵌套类/接口
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
字段摘要
protected static Border noFocusBorder
           
 
从类 javax.swing.JLabel 继承的字段
labelFor
 
从类 javax.swing.JComponent 继承的字段
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
从类 java.awt.Component 继承的字段
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
从接口 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
 
从接口 java.awt.image.ImageObserver 继承的字段
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
构造方法摘要
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, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, 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, transferFocusBackward, 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, 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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

noFocusBorder

protected static Border noFocusBorder
构造方法详细信息

DefaultTableCellRenderer

public DefaultTableCellRenderer()
创建一个默认的表单元格渲染器。

方法详细信息

setForeground

public void setForeground(Color c)
重写 JComponent.setForeground 将未选定单元格的前景色分配为指定颜色。

覆盖:
JComponent 中的 setForeground
参数:
c - 将前景色设置为此值
另请参见:
Component.getForeground()

setBackground

public void setBackground(Color c)
重写 JComponent.setBackground 将未选定单元格的背景色分配为指定颜色。

覆盖:
JComponent 中的 setBackground
参数:
c - 将背景色设置为此值
另请参见:
Component.getBackground()

updateUI

public void updateUI()
来自 UIManager 的关于外观 [L&F] 已更改的通知。用来自 UIManager 的最新版本 UI 对象替换当前的 UI 对象。

覆盖:
JLabel 中的 updateUI
另请参见:
JComponent.updateUI()

getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
返回默认的表单元格渲染器。

指定者:
接口 TableCellRenderer 中的 getTableCellRendererComponent
参数:
table - JTable
value - 分配给 [row, column] 处单元格的值
isSelected - 如果已选定单元格,则为 true
hasFocus - 如果单元格具有焦点,则为 true
row - 要呈现的单元格所在行
column - 要呈现的单元格所在列
返回:
默认的表单元格渲染器

isOpaque

public boolean isOpaque()
因为性能原因而被重写。有关更多详细信息,请参见实现注意事项

覆盖:
JComponent 中的 isOpaque
返回:
如果此组件是完全不透明的,则返回 true
另请参见:
JComponent.setOpaque(boolean)

invalidate

public void invalidate()
因为性能原因而被重写。有关更多详细信息,请参见实现注意事项

覆盖:
Container 中的 invalidate
从以下版本开始:
1.5
另请参见:
Container.validate(), Container.layout(), LayoutManager

validate

public void validate()
因为性能原因而被重写。有关更多详细信息,请参见实现注意事项

覆盖:
Container 中的 validate
另请参见:
Container.add(java.awt.Component), Component.invalidate(), JComponent.revalidate()

微信小程序

微信扫一扫体验

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部