public class BasicComboPopup extends JPopupMenu implements ComboPopup
ComboPopup
接口。
该类代表组合框的弹出部分的ui。
所有事件处理由使用createxxxListener()
方法和内部类创建的侦听器类来处理。 您可以通过覆盖createxxxListener()
方法并提供自己的事件侦听器或从此类中提供的子类化来更改此类的行为。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,对所有JavaBeans的长期存储的支持已经添加到java.beans
包中。 请参阅XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
class |
BasicComboPopup.InvocationKeyHandler
从Java 2平台v 1.4开始,此类现在已经过时,仅用于向后兼容API。
|
protected class |
BasicComboPopup.InvocationMouseHandler
在组合框(
而不是其弹出菜单)上注册的侦听器来处理影响弹出菜单状态的鼠标事件。
|
protected class |
BasicComboPopup.InvocationMouseMotionHandler
如果拖动列表,该监听器将监视拖动并更新列表中的当前选择。
|
protected class |
BasicComboPopup.ItemHandler
此监听器监视组合框中对选择的更改。
|
class |
BasicComboPopup.ListDataHandler
从1.4开始,这个类现在已经过时了,不做任何事情,只能包含用于向后兼容的API。
|
protected class |
BasicComboPopup.ListMouseHandler
当列表中释放鼠标时,此侦听器会隐藏弹出窗口。
|
protected class |
BasicComboPopup.ListMouseMotionHandler
当您将鼠标移动到列表上时,此侦听器将更改所选项。
|
protected class |
BasicComboPopup.ListSelectionHandler
从Java 2平台v 1.4开始,这个类现在已经过时了,不做任何事情,只包含在后端的API兼容性中。
|
protected class |
BasicComboPopup.PropertyChangeHandler
该监听器监视组合框中已更改的绑定属性。
|
JPopupMenu.AccessibleJPopupMenu, JPopupMenu.Separator
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected Timer |
autoscrollTimer
此保护字段是实现特定的。
|
protected JComboBox |
comboBox |
protected boolean |
hasEntered |
protected boolean |
isAutoScrolling |
protected ItemListener |
itemListener
此保护字段是实现特定的。
|
protected KeyListener |
keyListener
此保护字段是实现特定的。
|
protected JList |
list
此保护字段是实现特定的。
|
protected ListDataListener |
listDataListener
此保护字段是实现特定的。
|
protected MouseListener |
listMouseListener
此保护字段是实现特定的。
|
protected MouseMotionListener |
listMouseMotionListener
此保护字段是实现特定的。
|
protected ListSelectionListener |
listSelectionListener
此保护字段是实现特定的。
|
protected MouseListener |
mouseListener
此保护字段是实现特定的。
|
protected MouseMotionListener |
mouseMotionListener
此保护字段是实现特定的。
|
protected PropertyChangeListener |
propertyChangeListener
此保护字段是实现特定的。
|
protected static int |
SCROLL_DOWN |
protected static int |
SCROLL_UP |
protected int |
scrollDirection |
protected JScrollPane |
scroller
此保护字段是实现特定的。
|
protected boolean |
valueIsAdjusting
从Java 2平台v1.4起,这个以前未记录的字段已不再使用了。
|
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
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
BasicComboPopup(JComboBox combo) |
Modifier and Type | Method and Description |
---|---|
protected void |
autoScrollDown()
此受保护方法是实现特定的,应该是私有的。
|
protected void |
autoScrollUp()
此受保护方法是实现特定的,应该是私有的。
|
protected Rectangle |
computePopupBounds(int px, int py, int pw, int ph)
基于组合框位置和封闭屏幕边界,计算组合框的弹出部分的位置和大小。
|
protected void |
configureList()
配置用于在弹出窗口中保存组合框项目的列表。
|
protected void |
configurePopup()
配置组合框的弹出部分。
|
protected void |
configureScroller()
配置在组合框弹出窗口中保存列表的可滚动部分。
|
protected MouseEvent |
convertMouseEvent(MouseEvent e) |
protected ItemListener |
createItemListener()
创建一个
ItemListener ,它将被添加到组合框中。
|
protected KeyListener |
createKeyListener()
创建将添加到组合框的关键侦听器。
|
protected JList |
createList()
创建弹出窗口中使用的JList,以显示组合框模型中的项目。
|
protected ListDataListener |
createListDataListener()
创建将添加到
ComboBoxModel 的列表数据监听器。
|
protected MouseListener |
createListMouseListener()
创建一个鼠标监听器,在弹出的列表中监视鼠标事件。
|
protected MouseMotionListener |
createListMouseMotionListener()
创建一个鼠标移动侦听器,在弹出的列表中监视鼠标移动事件。
|
protected ListSelectionListener |
createListSelectionListener()
创建一个列表选择监听器,用于在弹出列表中监视选择更改。
|
protected MouseListener |
createMouseListener()
创建一个监听器,它将在组合框上观察鼠标按键和释放事件。
|
protected MouseMotionListener |
createMouseMotionListener()
创建将添加到组合框的鼠标移动侦听器。
|
protected PropertyChangeListener |
createPropertyChangeListener()
创建一个
PropertyChangeListener ,它将被添加到组合框中。
|
protected JScrollPane |
createScroller()
创建容纳可滚动列表的滚动窗格。
|
protected void |
delegateFocus(MouseEvent e)
这是一种实用方法,可帮助事件处理程序在弹出弹出窗口时找出发送焦点的位置。
|
protected void |
firePopupMenuCanceled()
通知
PopupMenuListeners 此弹出菜单被取消。
|
protected void |
firePopupMenuWillBecomeInvisible()
通知
PopupMenuListener s这个弹出菜单将变得不可见。
|
protected void |
firePopupMenuWillBecomeVisible()
通知
PopupMenuListener s这个弹出菜单将变得可见。
|
AccessibleContext |
getAccessibleContext()
获取与此BasicComboPopup关联的AccessibleContext。
|
KeyListener |
getKeyListener()
实现ComboPopup.getKeyListener()。
|
JList |
getList()
实现ComboPopup.getList()。
|
MouseListener |
getMouseListener()
实现ComboPopup.getMouseListener()。
|
MouseMotionListener |
getMouseMotionListener()
实现ComboPopup.getMouseMotionListener()。
|
protected int |
getPopupHeightForRowCount(int maxRowCount)
根据当前的ListCellRenderer和最大行数检索弹出窗口的高度。
|
void |
hide()
实现ComboPopup.hide()。
|
protected void |
installComboBoxListeners()
此方法将必要的侦听器添加到JComboBox。
|
protected void |
installComboBoxModelListeners(ComboBoxModel model)
在组合框模型上安装侦听器。
|
protected void |
installKeyboardActions() |
protected void |
installListListeners()
将侦听器添加到列表控件。
|
boolean |
isFocusTraversable()
覆盖无条件返回假。
|
void |
show()
实现ComboPopup.show()。
|
protected void |
startAutoScrolling(int direction)
此受保护方法是实现特定的,应该是私有的。
|
protected void |
stopAutoScrolling()
此受保护方法是实现特定的,应该是私有的。
|
protected void |
togglePopup()
使弹出窗口可见,如果它是隐藏的,并使其隐藏,如果它是可见的。
|
protected void |
uninstallComboBoxModelListeners(ComboBoxModel model)
从组合框模型中删除侦听器
|
void |
uninstallingUI()
当UI卸载时调用。
|
protected void |
uninstallKeyboardActions() |
protected void |
updateListBoxSelectionForEvent(MouseEvent anEvent, boolean shouldScroll)
事件侦听器使用的实用方法。
|
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, updateUI
addAncestorListener, 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, 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, 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, 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, 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, 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, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isVisible
protected JComboBox comboBox
protected JList list
getList()
,
createList()
protected JScrollPane scroller
createScroller()
protected boolean valueIsAdjusting
protected MouseMotionListener mouseMotionListener
protected MouseListener mouseListener
protected KeyListener keyListener
getKeyListener()
,
createKeyListener()
protected ListSelectionListener listSelectionListener
protected MouseListener listMouseListener
protected MouseMotionListener listMouseMotionListener
protected PropertyChangeListener propertyChangeListener
protected ListDataListener listDataListener
createListDataListener()
protected ItemListener itemListener
createItemListener()
protected Timer autoscrollTimer
protected boolean hasEntered
protected boolean isAutoScrolling
protected int scrollDirection
protected static final int SCROLL_UP
protected static final int SCROLL_DOWN
public BasicComboPopup(JComboBox combo)
public void show()
show
在界面
ComboPopup
show
在
Component
public void hide()
hide
在界面
ComboPopup
hide
在
JComponent
public JList getList()
getList
在界面
ComboPopup
public MouseListener getMouseListener()
getMouseListener
在接口
ComboPopup
MouseListener
或null
ComboPopup.getMouseListener()
public MouseMotionListener getMouseMotionListener()
getMouseMotionListener
在界面
ComboPopup
MouseMotionListener
或null
ComboPopup.getMouseMotionListener()
public KeyListener getKeyListener()
getKeyListener
在接口
ComboPopup
KeyListener
或null
ComboPopup.getKeyListener()
public void uninstallingUI()
uninstallingUI
中的
ComboPopup
protected void uninstallComboBoxModelListeners(ComboBoxModel model)
model
- 组合框模型来安装监听器
installComboBoxModelListeners(javax.swing.ComboBoxModel)
protected void uninstallKeyboardActions()
protected void firePopupMenuWillBecomeVisible()
JPopupMenu
PopupMenuListener
这个弹出菜单将变得可见。
protected void firePopupMenuWillBecomeInvisible()
JPopupMenu
PopupMenuListener
s这个弹出菜单将变得不可见。
protected void firePopupMenuCanceled()
JPopupMenu
PopupMenuListeners
该弹出菜单被取消。
protected MouseListener createMouseListener()
MouseListener
将被添加到组合框或null
protected MouseMotionListener createMouseMotionListener()
MouseMotionListener
将被添加到组合框或null
protected KeyListener createKeyListener()
KeyListener
或null
protected ListSelectionListener createListSelectionListener()
ListSelectionListener
的实例或null
protected ListDataListener createListDataListener()
ComboBoxModel
的列表数据监听器。
如果此方法返回null,则不会将其添加到组合框模型中。
ListDataListener
的实例或null
protected MouseListener createListMouseListener()
MouseListener
的实例或null
protected MouseMotionListener createListMouseMotionListener()
MouseMotionListener
或null的实例
protected PropertyChangeListener createPropertyChangeListener()
PropertyChangeListener
,它将被添加到组合框中。
如果此方法返回null,则不会将其添加到组合框中。
PropertyChangeListener
的实例或null
protected ItemListener createItemListener()
ItemListener
将被添加到组合框。
如果此方法返回null,则不会将其添加到组合框中。
子类可以覆盖此方法以返回自己的ItemEvent处理程序的实例。
ItemListener
的实例或null
protected JList createList()
JList
用于显示组合框项目
protected void configureList()
createList()
protected void installListListeners()
protected JScrollPane createScroller()
protected void configureScroller()
protected void configurePopup()
protected void installComboBoxListeners()
protected void installComboBoxModelListeners(ComboBoxModel model)
uninstallComboBoxModelListeners
任何监听器应在uninstallComboBoxModelListeners
中uninstallComboBoxModelListeners
。
model
- 组合框模型来安装监听器
uninstallComboBoxModelListeners(javax.swing.ComboBoxModel)
protected void installKeyboardActions()
public boolean isFocusTraversable()
isFocusTraversable
在
Component
true
如果这个Component
是可对焦的;
false
否则
Component.setFocusable(boolean)
protected void startAutoScrolling(int direction)
protected void stopAutoScrolling()
protected void autoScrollUp()
protected void autoScrollDown()
public AccessibleContext getAccessibleContext()
getAccessibleContext
在接口
Accessible
getAccessibleContext
在
JPopupMenu
类
protected void delegateFocus(MouseEvent e)
protected void togglePopup()
protected MouseEvent convertMouseEvent(MouseEvent e)
protected int getPopupHeightForRowCount(int maxRowCount)
protected Rectangle computePopupBounds(int px, int py, int pw, int ph)
px
- 启动x位置
py
- 开始y位置
pw
- 起始宽度
ph
- 起始高度
protected void updateListBoxSelectionForEvent(MouseEvent anEvent, boolean shouldScroll)
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.