public class BasicComboBoxRenderer extends JLabel implements ListCellRenderer, Serializable
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。
从1.4开始,支持所有JavaBeans的长期存储已经添加到java.beans包中。 请参阅XMLEncoder 。
| Modifier and Type | Class and Description |
|---|---|
static class |
BasicComboBoxRenderer.UIResource
BasicComboBoxRenderer的子类实现UIResource。
|
JLabel.AccessibleJLabelJComponent.AccessibleJComponent
Container.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected static Border |
noFocusBorder
一个空的
Border 。
|
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, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES,
SOMEBITS, WIDTH
| Constructor and Description |
|---|
BasicComboBoxRenderer()
|
| Modifier and Type | Method and Description |
|---|---|
Component |
getListCellRendererComponent(JList list,
Object value,
int index, boolean isSelected, boolean cellHasFocus)
返回已配置为显示指定值的组件。
|
Dimension |
getPreferredSize()
如果
preferredSize已被设置为非
null值,则返回它。
|
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,
updateUIaddAncestorListener,
addNotify, addVetoableChangeListener,
computeVisibleRect,
contains, createToolTip,
disable, enable, firePropertyChange,
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,
getRegisteredKeyStrokes,
getRootPane, getSize,
getToolTipLocation,
getToolTipText,
getToolTipText,
getTopLevelAncestor,
getTransferHandler,
getVerifyInputWhenFocusTarget,
getVetoableChangeListeners,
getVisibleRect,
getWidth, getX, getY, grabFocus, hide, isDoubleBuffered,
isLightweightComponent,
isManagingFocus,
isOpaque, 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,
repaint,
repaint,
requestDefaultFocus,
requestFocus,
requestFocus,
requestFocusInWindow,
requestFocusInWindow,
resetKeyboardActions,
reshape,
revalidate, 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, invalidate, 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,
validate, 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,
firePropertyChange,
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, 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,
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
Border 。
此字段可能不会被使用。
要改变Border通过此渲染器用于使用所述直接设置它setBorder方法。
public Dimension getPreferredSize()
JComponent
preferredSize已经设置为非null值,则返回它。
如果UI代理的getPreferredSize方法返回一个非null值,那么返回那个;
否则推迟到组件的布局管理器。
getPreferredSize在
JComponent
preferredSize属性
JComponent.setPreferredSize(java.awt.Dimension) , ComponentUI
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
ListCellRenderer复制
paint方法来“渲染”单元。
如果需要计算列表的维度,因为列表单元格不具有固定的大小,则调用此方法来生成可调用getPreferredSize 。
getListCellRendererComponent在界面
ListCellRenderer
list - 我们正在画的JList
value - 由list.getModel()返回的值getElementAt(index)。
index - 细胞指数。
isSelected - 如果指定的单元格被选中,则为真。
cellHasFocus - 如果指定的单元格具有焦点,则为真。
JList , ListSelectionModel , ListModel