java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPopupMenu
javax.swing.plaf.basic.BasicComboPopup
- 所有已实现的接口:
-
ImageObserver,MenuContainer,Serializable,Accessible,MenuElement,ComboPopup
- 直接已知的子类:
-
MetalComboBoxUI.MetalComboPopup
这是
ComboPopup接口的基本实现。该类表示组合框弹出部分的UI。
所有事件处理都由使用createxxxListener()方法和内部类创建的监听器类处理。您可以通过覆盖createxxxListener()方法并提供自己的事件监听器或从此类提供的监听器子类化来更改此类的行为。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans包中。请参见XMLEncoder。
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass从Java 2平台v 1.4开始,此类现已过时,仅包含用于向后API兼容性的内容。protected class一个要注册到组合框(而不是其弹出菜单)以处理影响弹出菜单状态的鼠标事件的监听器。protected class此监听器监视拖动并在拖动到列表上方时更新列表中的当前选择项。protected class此监听器监视组合框中选择的更改。class从1.4开始,此类现已过时,不执行任何操作,仅包含用于向后API兼容性的内容。protected class当鼠标在列表中释放时,此监听器隐藏弹出菜单。protected class当您在列表上移动鼠标时,此监听器更改所选项目。protected class从Java 2平台v 1.4开始,此类现已过时,不执行任何操作,仅包含用于向后API兼容性的内容。protected class此监听器监视组合框中已更改的绑定属性。Nested classes/interfaces declared in class javax.swing.JPopupMenu
JPopupMenu.AccessibleJPopupMenu, JPopupMenu.SeparatorNested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Timer此受保护字段是特定于实现的。JComboBox的实例。protected boolean如果鼠标光标在弹出菜单中,则为true。protected boolean如果为true,则启用自动滚动。protected ItemListener此受保护字段是特定于实现的。protected KeyListener此受保护字段是特定于实现的。此受保护字段是特定于实现的。protected ListDataListener此受保护字段是特定于实现的。protected MouseListener此受保护字段是特定于实现的。protected MouseMotionListener此受保护字段是特定于实现的。protected ListSelectionListener此受保护字段是特定于实现的。protected MouseListener此受保护字段是特定于实现的。protected MouseMotionListener此受保护字段是特定于实现的。protected PropertyChangeListener此受保护字段是特定于实现的。protected static final int向下滚动的方向。protected static final int向上滚动的方向。protected int滚动的方向。protected JScrollPane此受保护字段是特定于实现的。protected boolean从Java 2平台v1.4开始,此先前未记录的字段不再使用。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_WINDOWFields declared in class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void此受保护方法是特定于实现的,应为私有。protected void此受保护方法是特定于实现的,应为私有。protected RectanglecomputePopupBounds(int px, int py, int pw, int ph) 根据组合框位置和包围屏幕边界,计算组合框弹出部分的放置和大小。protected void配置用于在弹出窗口中保存组合框项目的列表。protected void配置组合框的弹出部分。protected void配置包含组合框弹出窗口中列表的可滚动部分。protected MouseEvent转换鼠标事件。protected ItemListener创建一个将添加到组合框的ItemListener。protected KeyListener创建将添加到组合框的键盘监听器。创建用于在弹出窗口中显示组合框模型中项目的JList。protected ListDataListener创建将添加到ComboBoxModel的列表数据监听器。protected MouseListener创建监视弹出窗口列表中鼠标事件的鼠标监听器。protected MouseMotionListener创建监视弹出窗口列表中鼠标移动事件的鼠标移动监听器。protected ListSelectionListener创建监视弹出窗口列表中选择更改的列表选择监听器。protected MouseListener创建将监视组合框上的鼠标按下和释放事件的监听器。protected MouseMotionListener创建将添加到组合框的鼠标移动监听器。protected PropertyChangeListener创建将添加到组合框的PropertyChangeListener。protected JScrollPane创建容纳可滚动列表的滚动窗格。protected void这是一个实用方法,帮助事件处理程序确定在弹出窗口弹出时将焦点发送到何处。获取与此BasicComboPopup关联的AccessibleContext。ComboPopup.getKeyListener()的实现。getList()ComboPopup.getList()的实现。ComboPopup.getMouseListener()的实现。ComboPopup.getMouseMotionListener()的实现。protected intgetPopupHeightForRowCount(int maxRowCount) 根据当前ListCellRenderer和最大行数检索弹出窗口的高度。voidhide()ComboPopup.hide()的实现。protected void此方法向JComboBox添加必要的监听器。protected voidinstallComboBoxModelListeners(ComboBoxModel<?> model) 在组合框模型上安装监听器。protected void注册键盘操作。protected void将监听器添加到列表控件。boolean被覆盖以无条件地返回false。voidshow()ComboPopup.show()的实现。protected voidstartAutoScrolling(int direction) 此受保护方法是特定于实现的,应为私有。protected void此受保护方法是特定于实现的,应为私有。protected void如果隐藏,则使弹出窗口可见,如果可见,则隐藏。protected voiduninstallComboBoxModelListeners(ComboBoxModel<?> model) 从组合框模型中删除监听器void当UI正在卸载时调用。protected void注销键盘操作。protected voidupdateListBoxSelectionForEvent(MouseEvent anEvent, boolean shouldScroll) 事件监听器使用的实用方法。Methods declared in class javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, updateUIMethods declared in class 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, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, unregisterKeyboardAction, updateMethods 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, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods 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, firePropertyChange, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods declared in interface javax.swing.plaf.basic.ComboPopup
isVisible
-
Field Details
-
comboBox
JComboBox的实例。 -
list
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用访问器方法。- 参见:
-
scroller
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用创建方法。- 参见:
-
valueIsAdjusting
protected boolean valueIsAdjusting从Java 2平台v1.4开始,此先前未记录的字段不再使用。 -
mouseMotionListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用访问器或创建方法。- 参见:
-
mouseListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用访问器或创建方法。- 参见:
-
keyListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用访问器或创建方法。- 参见:
-
listSelectionListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用创建方法。- 参见:
-
listMouseListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用创建方法。- 参见:
-
listMouseMotionListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用创建方法。- 参见:
-
propertyChangeListener
此受保护字段是特定于实现的。请勿直接访问或覆盖。请改用创建方法。- 参见:
-
listDataListener
这个受保护的字段是特定于实现的。不要直接访问或覆盖。请改用create方法- 参见:
-
itemListener
这个受保护的字段是特定于实现的。不要直接访问或覆盖。请改用create方法- 参见:
-
autoscrollTimer
这个受保护的字段是特定于实现的。不要直接访问或覆盖。 -
hasEntered
protected boolean hasEntered如果鼠标光标在弹出窗口中,则为true。 -
isAutoScrolling
protected boolean isAutoScrolling如果为true,则启用自动滚动。 -
scrollDirection
protected int scrollDirection滚动的方向。 -
SCROLL_UP
protected static final int SCROLL_UP向上滚动的方向。- 参见:
-
SCROLL_DOWN
protected static final int SCROLL_DOWN向下滚动的方向。- 参见:
-
-
Constructor Details
-
BasicComboPopup
构造一个BasicComboPopup的新实例。- 参数:
-
combo- 一个JComboBox的实例
-
-
Method Details
-
show
public void show()ComboPopup.show()的实现。- 指定者:
-
show在接口ComboPopup - 覆盖:
-
show在类Component
-
hide
public void hide()ComboPopup.hide()的实现。- 指定者:
-
hide在接口ComboPopup - 覆盖:
-
hide在类JComponent
-
getList
ComboPopup.getList()的实现。- 指定者:
-
getList在接口ComboPopup - 返回:
- 用于绘制组合框中项目的列表
-
getMouseListener
ComboPopup.getMouseListener()的实现。- 指定者:
-
getMouseListener在接口ComboPopup - 返回:
-
一个
MouseListener或null - 参见:
-
getMouseMotionListener
ComboPopup.getMouseMotionListener()的实现。- 指定者:
-
getMouseMotionListener在接口ComboPopup - 返回:
-
一个
MouseMotionListener或null - 参见:
-
getKeyListener
ComboPopup.getKeyListener()的实现。- 指定者:
-
getKeyListener在接口ComboPopup - 返回:
-
一个
KeyListener或null - 参见:
-
uninstallingUI
public void uninstallingUI()当UI正在卸载时调用。由于此弹出窗口不在组件树中,因此不会调用其uninstallUI()。它会移除在addComboBoxListeners()中添加的侦听器。- 指定者:
-
uninstallingUI在接口ComboPopup
-
uninstallComboBoxModelListeners
从组合框模型中移除侦听器- 参数:
-
model- 要安装侦听器的组合框模型 - 参见:
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()注销键盘操作。 -
createMouseListener
创建一个监听器,用于监视组合框上的鼠标按下和释放事件。 警告:在覆盖此方法时,请确保保持现有行为不变。- 返回:
-
一个将添加到组合框中的
MouseListener或null
-
createMouseMotionListener
创建将添加到组合框中的鼠标移动监听器。 警告:在覆盖此方法时,请确保保持现有行为不变。- 返回:
-
一个将添加到组合框中的
MouseMotionListener或null
-
createKeyListener
创建将添加到组合框中的键盘监听器。如果此方法返回null,则不会将其添加到组合框中。- 返回:
-
一个
KeyListener或null
-
createListSelectionListener
创建一个列表选择监听器,用于监视弹出列表中的选择更改。如果此方法返回null,则不会将其添加到弹出列表中。- 返回:
-
一个
ListSelectionListener的实例或null
-
createListDataListener
创建将添加到ComboBoxModel中的列表数据监听器。如果此方法返回null,则不会将其添加到组合框模型中。- 返回:
-
一个
ListDataListener的实例或null
-
createListMouseListener
创建一个鼠标监听器,用于监视弹出列表中的鼠标事件。如果此方法返回null,则不会将其添加到组合框中。- 返回:
-
一个
MouseListener的实例或null
-
createListMouseMotionListener
创建一个鼠标移动监听器,用于监视弹出列表中的鼠标移动事件。如果此方法返回null,则不会将其添加到组合框中。- 返回:
-
一个
MouseMotionListener的实例或null
-
createPropertyChangeListener
创建一个将添加到组合框中的PropertyChangeListener。如果此方法返回null,则不会将其添加到组合框中。- 返回:
-
一个
PropertyChangeListener的实例或null
-
createItemListener
创建一个将添加到组合框中的ItemListener。如果此方法返回null,则不会将其添加到组合框中。子类可以覆盖此方法以返回其自己的ItemEvent处理程序的实例。
- 返回:
-
一个
ItemListener的实例或null
-
createList
创建用于在弹出窗口中显示组合框模型中项目的JList。在创建UI类时调用此方法。- 返回:
-
用于显示组合框项目的
JList
-
configureList
protected void configureList()配置用于在弹出窗口中保存组合框项目的列表。在创建UI类时调用此方法。- 参见:
-
installListListeners
protected void installListListeners()将侦听器添加到列表控件。 -
createScroller
创建包含可滚动列表的滚动窗格。- 返回:
- 包含可滚动列表的滚动窗格
-
configureScroller
protected void configureScroller()配置在组合框弹出窗口中保存列表的可滚动部分。在创建UI类时调用此方法。 -
configurePopup
protected void configurePopup()配置组合框的弹出部分。在创建UI类时调用此方法。 -
installComboBoxListeners
protected void installComboBoxListeners()此方法向JComboBox添加必要的侦听器。 -
installComboBoxModelListeners
在组合框模型上安装侦听器。在组合框模型上安装的任何侦听器应在uninstallComboBoxModelListeners中移除。- 参数:
-
model- 要安装侦听器的组合框模型 - 参见:
-
installKeyboardActions
protected void installKeyboardActions()注册键盘操作。 -
isFocusTraversable
public boolean isFocusTraversable()被覆盖以无条件地返回false。- 覆盖:
-
isFocusTraversable在类Component - 返回:
-
如果此
Component可聚焦,则为true;否则为false
-
startAutoScrolling
protected void startAutoScrolling(int direction) 这个受保护的方法是特定于实现的,应该是私有的。不要调用或覆盖。- 参数:
-
direction- 滚动的方向
-
stopAutoScrolling
protected void stopAutoScrolling()这个受保护的方法是特定于实现的,应该是私有的。不要调用或覆盖。 -
autoScrollUp
protected void autoScrollUp()这个受保护的方法是特定于实现的,应该是私有的。不要调用或覆盖。 -
autoScrollDown
protected void autoScrollDown()这个受保护的方法是特定于实现的,应该是私有的。不要调用或覆盖。 -
getAccessibleContext
获取与此BasicComboPopup关联的AccessibleContext。AccessibleContext将其父级设置为ComboBox。- 指定者:
-
getAccessibleContext在接口Accessible - 覆盖:
-
getAccessibleContext在类JPopupMenu - 返回:
- BasicComboPopup的AccessibleContext
- 自从:
- 1.5
-
delegateFocus
这是一个实用方法,帮助事件处理程序确定在弹出窗口弹出时将焦点发送到何处。标准实现将焦点委托给编辑器(如果组合框是可编辑的)或者如果不可编辑,则委托给JComboBox。- 参数:
-
e- 鼠标事件
-
togglePopup
protected void togglePopup()如果弹出窗口是隐藏的,则使其可见,如果弹出窗口是可见的,则使其隐藏。 -
convertMouseEvent
转换鼠标事件。- 参数:
-
e- 鼠标事件 - 返回:
- 转换后的鼠标事件
-
getPopupHeightForRowCount
protected int getPopupHeightForRowCount(int maxRowCount) 根据当前的ListCellRenderer和最大行数检索弹出窗口的高度。- 参数:
-
maxRowCount- 行数 - 返回:
- 弹出窗口的高度
-
computePopupBounds
根据组合框位置和包围屏幕边界计算组合框弹出部分的放置和大小。如果不需要转换,则返回的矩形将具有与参数相同的值。- 参数:
-
px- 起始x位置 -
py- 起始y位置 -
pw- 起始宽度 -
ph- 起始高度 - 返回:
- 代表弹出窗口放置和大小的矩形
-
updateListBoxSelectionForEvent
事件侦听器使用的实用方法。给定鼠标事件,将列表选择更改为鼠标下方的列表项。- 参数:
-
anEvent- 鼠标事件 -
shouldScroll- 如果为true,则应滚动列表。
-