©
本文檔使用 php中文網手册 發布
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JLabel javax.swing.table.DefaultTableCellRenderer
public class DefaultTableCellRenderer
呈现(显示) JTable
中每个单元格的标准类。
实现注意事项:此类继承自一个标准的组件类 JLabel
。但是 JTable
为其单元格的呈现使用了特殊的机制,因此要求稍微对其单元格渲染器的行为进行修改。该 table 类定义一个单元格渲染器,并将其用作呈现表中所有单元格的橡皮图章;它呈现第一个单元格、更改该单元格渲染器的内容、将原点移到新的位置、重新进行绘制,等等。标准的 JLabel
组件不是通过此方式使用的,每次绘制单元格时,我们都希望避免触发 revalidate
事件。这会大大降低程序的性能,因为 revalidate
消息会沿容器的层次结构向上传递,以确定任意其他组件是否将受到影响。由于该渲染器是绘制操作生命周期中唯一的父类,类似地,我们也希望避免与为进行绘制操作而遍历容器层次结构相关联的开销。所以此类将 validate
、invalidate
、revalidate
、repaint
和 firePropertyChange
方法重写为无操作,并单独重写 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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
字段摘要 | |
---|---|
protected static Border |
noFocusBorder
一个空 Border 。 |
从类 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, 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, 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 |
字段详细信息 |
---|
protected static Border noFocusBorder
Border
。可以不使用此字段。要更改此渲染器所使用的 Border
,请重写 getTableCellRendererComponent
方法并直接设置所返回组件的边界。
构造方法详细信息 |
---|
public DefaultTableCellRenderer()
方法详细信息 |
---|
public void setForeground(Color c)
JComponent.setForeground
将未选定单元格的前景色分配为指定颜色。
JComponent
中的 setForeground
c
- 将前景色设置为此值Component.getForeground()
public void setBackground(Color c)
JComponent.setBackground
将未选定单元格的背景色分配为指定颜色。
JComponent
中的 setBackground
c
- 将背景色设置为此值Component.getBackground()
,
JComponent.setOpaque(boolean)
public void updateUI()
UIManager
的关于外观 [L&F] 已更改的通知。用取自 UIManager
的最新版本 UI 对象替换当前的 UI 对象。
JLabel
中的 updateUI
JComponent.updateUI()
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
在打印操作期间,将调用此方法(isSelected
和 hasFocus
为 false
)阻止选择和焦点在打印输出中出现。要根据是否打印表进行其他定制,检查 JComponent.isPaintingForPrint()
的返回值。
TableCellRenderer
中的 getTableCellRendererComponent
table
- JTable
value
- 分配给 [row, column]
处单元格的值isSelected
- 如果已选定单元格,则为 truehasFocus
- 如果单元格具有焦点,则为 truerow
- 要呈现的单元格所在行column
- 要呈现的单元格所在列
JComponent.isPaintingForPrint()
public boolean isOpaque()
JComponent
中的 isOpaque
JComponent.setOpaque(boolean)
public void invalidate()
Container
中的 invalidate
Container.validate()
,
Container.layout()
,
LayoutManager
,
LayoutManager2.invalidateLayout(Container)
public void validate()
Container
中的 validate
Container.add(java.awt.Component)
,
Component.invalidate()
,
JComponent.revalidate()
,
Container.validateTree()
public void revalidate()
JComponent
中的 revalidate
Component.invalidate()
,
Container.validate()
,
JComponent.isValidateRoot()
,
RepaintManager.addInvalidComponent(javax.swing.JComponent)
public void repaint(long tm, int x, int y, int width, int height)
JComponent
中的 repaint
tm
- 不使用此参数x
- 脏区的 x 值y
- 脏区的 y 值width
- 脏区的宽度height
- 脏区的高度Component.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
public void repaint(Rectangle r)
JComponent
中的 repaint
r
- 包含脏区的 Rectangle
Component.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
public void repaint()
Component
中的 repaint
Component.update(Graphics)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
Component
中的 firePropertyChange
propertyName
- 其值已改变的属性oldValue
- 该属性以前的值newValue
- 该属性的新值public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
JComponent
中的 firePropertyChange
propertyName
- 其值已更改的属性oldValue
- 该属性以前的值newValue
- 该属性的新值protected void setValue(Object value)
String
对象设置为 value
。
value
- 此单元格的字符串值;如果 value 为 null
,则将文本值设置为空字符串JLabel.setText(java.lang.String)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。