javax.swing

接口
异常
java.lang.Object
  继承者 java.awt.Component
      继承者 java.awt.Container
          继承者 javax.swing.JComponent
              继承者 javax.swing.JLabel
                  继承者 javax.swing.DefaultListCellRenderer
所有已实现的接口:
ImageObserver, MenuContainer, Serializable, Accessible, ListCellRenderer, SwingConstants
直接已知子类:
DefaultListCellRenderer.UIResource, MetalFileChooserUI.FileRenderer, MetalFileChooserUI.FilterComboBoxRenderer

public class DefaultListCellRenderer
     
extends JLabel
implements ListCellRenderer, Serializable

呈现列表中的一个项。

实现注意事项: 此类重写 invalidatevalidaterevalidaterepaintisOpaquefirePropertyChange 只是为了提高性能。如果不重写这些方法,这些经常调用的方法将执行那些对于默认列表单元格渲染器不必要的代码路径。如果编写自己的渲染器,则要小心权衡重写这些方法的利弊。

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


嵌套类摘要
static class DefaultListCellRenderer.UIResource
          实现 UIResource 的 DefaultListCellRenderer 的子类。
 
从类 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
 
构造方法摘要
DefaultListCellRenderer()
          为列表中的项构造默认渲染器对象。
 
方法摘要
 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()
          因为性能原因而被重写。
 
从类 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
 
从类 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, 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, 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
 
从类 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, 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
一个空 Border。可以不使用此字段。要更改此渲染器所使用的 Border,需要重写 getListCellRendererComponent 方法并直接设置返回组件的边框。

构造方法详细信息

DefaultListCellRenderer

public DefaultListCellRenderer()
为列表中的项构造默认渲染器对象。

方法详细信息

getListCellRendererComponent

public Component getListCellRendererComponent(JList list,
                                              Object value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus)
从接口 ListCellRenderer 复制的描述
返回已配置用于显示指定值的组件。然后调用该组件的 paint 方法来“呈现”单元格。如果由于列表单元格没有固定的大小而有必要计算该列表的尺寸,则调用此方法来生成一个可在其上调用 getPreferredSize 的组件。

指定者:
接口 ListCellRenderer 中的 getListCellRendererComponent
参数:
list - 正在绘制的 JList。
value - 由 list.getModel().getElementAt(index) 返回的值。
index - 单元格索引。
isSelected - 如果选择了指定的单元格,则为 true。
cellHasFocus - 如果指定的单元格拥有焦点,则为 true。
返回:
其 paint() 方法将呈现指定值的组件。
另请参见:
JList, ListSelectionModel, ListModel

isOpaque

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

覆盖:
JComponent 中的 isOpaque
返回:
如果背景是完全不透明的并且不同于 JList 的背景,则返回 true,否则返回 false
从以下版本开始:
1.5
另请参见:
JComponent.setOpaque(boolean)

validate

public void validate()
因为性能原因而被重写