java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
javax.swing.DefaultListCellRenderer
- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
,ListCellRenderer<Object>
,SwingConstants
- 直接已知的子类:
-
DefaultListCellRenderer.UIResource
,MetalFileChooserUI.FileRenderer
,MetalFileChooserUI.FilterComboBoxRenderer
public class DefaultListCellRenderer extends JLabel implements ListCellRenderer<Object>, Serializable
渲染列表中的项目。
实现说明: 此类仅覆盖invalidate
、validate
、revalidate
、repaint
、isOpaque
和firePropertyChange
方法,以提高性能。如果不进行覆盖,这些经常调用的方法将执行不必要的代码路径,对于默认的列表单元格渲染器是不必要的。如果您编写自己的渲染器,请注意权衡覆盖这些方法的利弊。
警告: 此类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4版本开始,已将所有JavaBeans的长期存储支持添加到java.beans
包中。请参阅XMLEncoder
。
- 自:
- 1.2
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DefaultListCellRenderer的一个子类,实现了UIResource。Nested classes/interfaces declared in class javax.swing.JLabel
JLabel.AccessibleJLabel
Nested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields declared in class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields declared in class 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) 出于性能原因而重写。void
firePropertyChange
(String propertyName, short oldValue, short newValue) 出于性能原因而重写。protected void
firePropertyChange
(String propertyName, Object oldValue, Object newValue) 出于性能原因而重写。getListCellRendererComponent
(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) 返回一个已配置为显示指定值的组件。void
出于性能原因而重写。boolean
isOpaque()
出于性能原因而重写。void
repaint()
出于性能原因而重写。void
repaint
(long tm, int x, int y, int width, int height) 出于性能原因而重写。void
出于性能原因而重写。void
出于性能原因而重写。void
validate()
出于性能原因而重写。Methods declared in class 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, updateUI
Methods declared in class javax.swing.JComponent
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
Methods declared in class 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
Methods declared in class 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, 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, 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
-
Field Details
-
noFocusBorder
无焦点边框
-
-
Constructor Details
-
DefaultListCellRenderer
public DefaultListCellRenderer()为列表中的项目构造一个默认的渲染器对象。
-
-
Method Details
-
getListCellRendererComponent
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) 从接口复制的描述:ListCellRenderer
返回一个已配置为显示指定值的组件。然后调用该组件的paint
方法来“渲染”单元格。如果需要计算列表的尺寸,因为列表单元格没有固定大小,将调用此方法生成一个组件,可以在其上调用getPreferredSize
。- 指定者:
-
getListCellRendererComponent
在接口ListCellRenderer<Object>
中 - 参数:
-
list
- 我们正在绘制的JList。 -
value
- 列表.getModel().getElementAt(index)返回的值。 -
index
- 单元格的索引。 -
isSelected
- 如果指定的单元格被选中,则为true。 -
cellHasFocus
- 如果指定的单元格具有焦点,则为true。 - 返回:
- 一个其paint()方法将渲染指定值的组件。
- 另请参阅:
-
isOpaque
public boolean isOpaque()出于性能原因而重写。更多信息请参阅实现说明。- 覆盖:
-
isOpaque
在类JComponent
中 - 返回:
-
如果背景完全不透明且与JList的背景不同,则为
true
;否则为false
- 自:
- 1.5
- 另请参阅:
-
validate
public void validate()出于性能原因而重写。更多信息请参阅实现说明。 -
invalidate
public void invalidate()出于性能原因而重写。更多信息请参阅实现说明。- 覆盖:
-
invalidate
在类Container
中 - 自:
- 1.5
- 另请参阅:
-
repaint
public void repaint()出于性能原因而重写。更多信息请参阅实现说明。 -
revalidate
public void revalidate()出于性能原因而重写。更多信息请参阅实现说明。- 覆盖:
-
revalidate
在类JComponent
中 - 另请参阅:
-
repaint
public void repaint(long tm, int x, int y, int width, int height) 出于性能原因而重写。更多信息请参阅实现说明。- 覆盖:
-
repaint
在类JComponent
中 - 参数:
-
tm
- 此参数未使用 -
x
- 脏区域的x值 -
y
- 脏区域的y值 -
width
- 脏区域的宽度 -
height
- 脏区域的高度 - 另请参阅:
-
repaint
出于性能原因而重写。更多信息请参阅实现说明。- 覆盖:
-
repaint
在类JComponent
中 - 参数:
-
r
- 包含脏区域的Rectangle
- 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 值已更改的属性 -
oldValue
- 属性的先前值 -
newValue
- 属性的新值
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为字节) -
newValue
- 属性的新值(作为字节) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为字符) -
newValue
- 属性的新值(作为字符) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为短整型) -
newValue
- 属性的新值(作为短整型) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类JComponent
中 - 参数:
-
propertyName
- 值已更改的属性 -
oldValue
- 属性的先前值 -
newValue
- 属性的新值
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为长整型) -
newValue
- 属性的新值(作为长整型) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为浮点数) -
newValue
- 属性的新值(作为浮点数) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类Component
中 - 参数:
-
propertyName
- 已更改的属性的程序名称 -
oldValue
- 属性的旧值(作为双精度浮点数) -
newValue
- 属性的新值(作为双精度浮点数) - 参见:
-
firePropertyChange
为了性能原因而重写。有关更多信息,请参阅实现说明。- 覆盖:
-
firePropertyChange
在类JComponent
中 - 参数:
-
propertyName
- 值已更改的属性 -
oldValue
- 属性的先前值 -
newValue
- 属性的新值
-