public class DefaultListCellRenderer extends JLabel implements ListCellRenderer<Object>, Serializable
Implementation Note:该类覆盖invalidate
, validate
, revalidate
, repaint
, isOpaque
和firePropertyChange
只是为了提高性能。 如果不被覆盖,这些经常被称为的方法将执行默认列表单元格渲染器不必要的代码路径。 如果您编写自己的渲染器,请注意重写这些方法的优点和缺点。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已经添加到java.beans
包中。 请参阅XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
static class |
DefaultListCellRenderer.UIResource
实现UIResource的DefaultListCellRenderer的子类。
|
JLabel.AccessibleJLabel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected static Border |
noFocusBorder |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DefaultListCellRenderer()
为列表中的项构造一个默认渲染器对象。
|
Modifier and Type | Method and Description |
---|---|
void |
firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, byte oldValue, byte newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, char oldValue, char newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, double oldValue, double newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, float oldValue, float newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, int oldValue, int newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, long oldValue, long newValue)
由于性能原因而被覆盖。
|
protected void |
firePropertyChange(String propertyName, Object oldValue, Object newValue)
由于性能原因而被覆盖。
|
void |
firePropertyChange(String propertyName, short oldValue, short newValue)
由于性能原因而被覆盖。
|
Component |
getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
返回已配置为显示指定值的组件。
|
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 |
validate()
由于性能原因而被覆盖。
|
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, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, hide, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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
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, 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, 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, transferFocusBackward, transferFocusUpCycle
protected static Border noFocusBorder
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
ListCellRenderer
paint
方法“渲染”单元。
如果需要计算列表的维度,因为列表单元格不具有固定大小,则调用此方法来生成可调用getPreferredSize
。
getListCellRendererComponent
在接口
ListCellRenderer<Object>
list
- 我们正在画的JList。
value
- 由list.getModel()返回的值getElementAt(index)。
index
- 细胞指数。
isSelected
- 如果指定的单元格被选中,则为真。
cellHasFocus
- 如果指定的单元格具有焦点,则为真。
JList
, ListSelectionModel
, ListModel
public boolean isOpaque()
isOpaque
在
JComponent
true
如果背景完全不透明,并且与JList的背景不同;
false
否则
JComponent.setOpaque(boolean)
public void validate()
public void invalidate()
invalidate
在
Container
Container.validate()
, Container.layout()
, LayoutManager2
public void repaint()
repaint
在
Component
Component.update(Graphics)
public void revalidate()
public void repaint(long tm, int x, int y, int width, int height)
repaint
在
JComponent
tm
- 不使用此参数
x
- 脏区域的x值
y
- 脏区域的y值
width
- 脏区域的宽度
height
- 脏区域的高度
JComponent.isPaintingOrigin()
,
Component.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
public void repaint(Rectangle r)
repaint
在
JComponent
r
- 一个
Rectangle
脏区域的
Rectangle
JComponent.isPaintingOrigin()
,
Component.isShowing()
,
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
firePropertyChange
在
Component
propertyName
- 其值已更改的属性
oldValue
- 该物业的以前的价值
newValue
- 该物业的新值
public void firePropertyChange(String propertyName, byte oldValue, byte newValue)
firePropertyChange
在
Component
类
propertyName
- 已更改的属性的编程名称
oldValue
- 属性的旧值(作为一个字节)
newValue
- 属性的新值(以字节为单位)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, char oldValue, char newValue)
firePropertyChange
在
JComponent
propertyName
- 已更改的属性的编程名称
oldValue
- 属性的旧值(作为char)
newValue
- 属性的新值(作为char)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, short oldValue, short newValue)
firePropertyChange
在类
Component
propertyName
- 已更改的属性的编程名称
oldValue
- 物业的旧价值(作为短期)
newValue
- 物业的旧价值(作为短期)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, int oldValue, int newValue)
firePropertyChange
在
JComponent
propertyName
- 其值已更改的属性
oldValue
- 该物业的以前的价值
newValue
- 该物业的新值
public void firePropertyChange(String propertyName, long oldValue, long newValue)
firePropertyChange
在
Component
propertyName
- 已更改的属性的编程名称
oldValue
- 物业的旧价值(长期)
newValue
- 物业的新价值(一样长)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, float oldValue, float newValue)
firePropertyChange
在
Component
propertyName
- 已更改的属性的编程名称
oldValue
- 属性的旧值(作为浮点数)
newValue
- 属性的新值(作为浮点数)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, double oldValue, double newValue)
firePropertyChange
在
Component
propertyName
- 已更改的属性的编程名称
oldValue
- 该属性的旧值(双重)
newValue
- 该属性的新值(双重)
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
firePropertyChange
在类
JComponent
propertyName
- 其值已更改的属性
oldValue
- 该物业的以前的价值
newValue
- the property's new value
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.