模块 java.desktop

类 BasicComboPopup

所有已实现的接口:
ImageObserver , MenuContainer , Serializable , Accessible , MenuElement , ComboPopup
已知子类:
MetalComboBoxUI.MetalComboPopup

public class BasicComboPopup extends JPopupMenu implements ComboPopup
这是 ComboPopup 接口的基本实现。此类表示组合框弹出部分的用户界面。

所有事件处理都由使用createxxxListener() 方法和内部类创建的监听器类处理。您可以通过覆盖 createxxxListener() 方法并提供您自己的事件监听器或从此类中提供的事件监听器进行子类化来更改此类的行为。

Warning: 此类的序列化对象将与未来的 Swing 版本不兼容。当前的序列化支持适用于运行相同版本 Swing 的应用程序之间的短期存储或 RMI。从 1.4 开始,对所有 JavaBeans 的长期存储的支持已添加到 java.beans 包中。请参阅 XMLEncoder

  • 字段详细信息

    • comboBox

      protected JComboBox <Object > comboBox
      JComboBox 的实例。
    • list

      protected JList <Object > list
      该受保护字段是特定于实现的。不要直接访问或重写。请改用访问器方法。
      参见:
    • scroller

      protected JScrollPane  scroller
      该受保护字段是特定于实现的。不要直接访问或重写。改为使用 create 方法
      参见:
    • valueIsAdjusting

      protected boolean valueIsAdjusting
      从 Java 2 平台 v1.4 开始,不再使用这个以前未记录的字段。
    • mouseMotionListener

      protected MouseMotionListener  mouseMotionListener
      该受保护字段是特定于实现的。不要直接访问或重写。请改用访问器或创建方法。
      参见:
    • mouseListener

      protected MouseListener  mouseListener
      该受保护字段是特定于实现的。不要直接访问或重写。请改用访问器或创建方法。
      参见:
    • keyListener

      protected KeyListener  keyListener
      该受保护字段是特定于实现的。不要直接访问或重写。请改用访问器或创建方法。
      参见:
    • listSelectionListener

      protected ListSelectionListener  listSelectionListener
      该受保护字段是特定于实现的。不要直接访问或重写。请改用创建方法。
      参见:
    • listMouseListener

      protected MouseListener  listMouseListener
      该受保护字段是特定于实现的。不要直接访问或重写。请改用创建方法。
      参见:
    • listMouseMotionListener

      protected MouseMotionListener  listMouseMotionListener
      该受保护字段是特定于实现的。不要直接访问或重写。改为使用 create 方法
      参见:
    • propertyChangeListener

      protected PropertyChangeListener  propertyChangeListener
      该受保护字段是特定于实现的。不要直接访问或重写。改为使用 create 方法
      参见:
    • listDataListener

      protected ListDataListener  listDataListener
      该受保护字段是特定于实现的。不要直接访问或重写。改为使用 create 方法
      参见:
    • itemListener

      protected ItemListener  itemListener
      该受保护字段是特定于实现的。不要直接访问或重写。改为使用 create 方法
      参见:
    • autoscrollTimer

      protected Timer  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
      向下滚动的方向。
      参见:
  • 构造方法详细信息

    • BasicComboPopup

      public BasicComboPopup(JComboBox <Object > combo)
      构造一个 BasicComboPopup 新实例
      参数:
      combo - JComboBox 的实例
  • 方法详情

    • show

      public void show()
      ComboPopup.show() 的实现。
      指定者:
      show 在接口 ComboPopup
      重写:
      show 在类 Component
    • hide

      public void hide()
      ComboPopup.hide() 的实现。
      指定者:
      hide 在接口 ComboPopup
      重写:
      hide 在类 JComponent
    • getList

      public JList <Object > getList()
      ComboPopup.getList() 的实现。
      指定者:
      getList 在接口 ComboPopup
      返回:
      用于在组合框中绘制项目的列表
    • getMouseListener

      public MouseListener  getMouseListener()
      ComboPopup.getMouseListener() 的实现。
      指定者:
      getMouseListener 在接口 ComboPopup
      返回:
      MouseListener 或空
      参见:
    • getMouseMotionListener

      public MouseMotionListener  getMouseMotionListener()
      ComboPopup.getMouseMotionListener() 的实现。
      指定者:
      getMouseMotionListener 在接口 ComboPopup
      返回:
      MouseMotionListener 或空
      参见:
    • getKeyListener

      public KeyListener  getKeyListener()
      ComboPopup.getKeyListener() 的实现。
      指定者:
      getKeyListener 在接口 ComboPopup
      返回:
      KeyListener 或空
      参见:
    • uninstallingUI

      public void uninstallingUI()
      在 UI 卸载时调用。由于此弹出窗口不在组件树中,因此不会调用它的 uninstallUI()。它删除了在 addComboBoxListeners() 中添加的监听。
      指定者:
      uninstallingUI 在接口 ComboPopup
    • uninstallComboBoxModelListeners

      protected void uninstallComboBoxModelListeners(ComboBoxModel <?> model)
      从组合框模型中删除监听
      参数:
      model - 安装监听器的组合框模型
      参见:
    • uninstallKeyboardActions

      protected void uninstallKeyboardActions()
      注销键盘操作。
    • createMouseListener

      protected MouseListener  createMouseListener()
      创建一个监听器,用于监视组合框上的鼠标按下和释放事件。 Warning:覆盖此方法时,请确保保持现有行为。
      返回:
      将添加到组合框的 MouseListener 或 null
    • createMouseMotionListener

      protected MouseMotionListener  createMouseMotionListener()
      创建将添加到组合框的鼠标运动监听器。 Warning:覆盖此方法时,请确保保持现有行为。
      返回:
      将添加到组合框的 MouseMotionListener 或 null
    • createKeyListener

      protected KeyListener  createKeyListener()
      创建将添加到组合框的键监听。如果此方法返回 null,则不会将其添加到组合框中。
      返回:
      KeyListener 或空
    • createListSelectionListener

      protected ListSelectionListener  createListSelectionListener()
      创建一个列表选择监听,用于监视弹出列表中的选择更改。如果此方法返回 null,则不会将其添加到弹出列表中。
      返回:
      ListSelectionListener 的实例或 null
    • createListDataListener

      protected ListDataListener  createListDataListener()
      创建一个将添加到 ComboBoxModel 的列表数据监听器。如果此方法返回 null,则不会将其添加到组合框模型中。
      返回:
      ListDataListener 的实例或 null
    • createListMouseListener

      protected MouseListener  createListMouseListener()
      创建一个鼠标监听,用于监视弹出列表中的鼠标事件。如果此方法返回 null,则不会将其添加到组合框中。
      返回:
      MouseListener 的实例或 null
    • createListMouseMotionListener

      protected MouseMotionListener  createListMouseMotionListener()
      创建一个鼠标运动监听,用于监视弹出列表中的鼠标运动事件。如果此方法返回 null,则不会将其添加到组合框中。
      返回:
      MouseMotionListener 的实例或 null
    • createPropertyChangeListener

      protected PropertyChangeListener  createPropertyChangeListener()
      创建将添加到组合框的 PropertyChangeListener。如果此方法返回 null,则不会将其添加到组合框中。
      返回:
      PropertyChangeListener 的实例或 null
    • createItemListener

      protected ItemListener  createItemListener()
      创建将添加到组合框的 ItemListener。如果此方法返回 null,则不会将其添加到组合框中。

      子类可以重写此方法以返回它们自己的 ItemEvent 处理程序的实例。

      返回:
      ItemListener 或 null 的实例
    • createList

      protected JList <Object > createList()
      创建弹出窗口中使用的 JList 以显示组合框模型中的项目。创建 UI 类时调用此方法。
      返回:
      JList 用于显示组合框项目
    • configureList

      protected void configureList()
      配置用于在弹出窗口中保存组合框项目的列表。创建 UI 类时调用此方法。
      参见:
    • installListListeners

      protected void installListListeners()
      将监听添加到列表控件。
    • createScroller

      protected JScrollPane  createScroller()
      创建包含可滚动列表的滚动窗格。
      返回:
      包含可滚动列表的滚动窗格
    • configureScroller

      protected void configureScroller()
      配置在组合框弹出窗口中保存列表的可滚动部分。创建 UI 类时调用此方法。
    • configurePopup

      protected void configurePopup()
      配置组合框的弹出部分。创建 UI 类时调用此方法。
    • installComboBoxListeners

      protected void installComboBoxListeners()
      此方法将必要的监听添加到 JComboBox。
    • installComboBoxModelListeners

      protected void installComboBoxModelListeners(ComboBoxModel <?> model)
      在组合框模型上安装监听器。组合框模型上安装的任何监听器都应在 uninstallComboBoxModelListeners 中删除。
      参数:
      model - 安装监听器的组合框模型
      参见:
    • installKeyboardActions

      protected void installKeyboardActions()
      注册键盘操作。
    • isFocusTraversable

      public boolean isFocusTraversable()
      重写以无条件返回 false。
      重写:
      isFocusTraversable 在类 Component
      返回:
      true 如果这个 Component 是可聚焦的; false否则
      参见:
    • startAutoScrolling

      protected void startAutoScrolling(int direction)
      这个受保护的方法是特定于实现的,应该是私有的。请勿调用或重写。
      参数:
      direction - 滚动方向
    • stopAutoScrolling

      protected void stopAutoScrolling()
      这个受保护的方法是特定于实现的,应该是私有的。请勿调用或重写。
    • autoScrollUp

      protected void autoScrollUp()
      这个受保护的方法是特定于实现的,应该是私有的。请勿调用或重写。
    • autoScrollDown

      protected void autoScrollDown()
      这个受保护的方法是特定于实现的,应该是私有的。请勿调用或重写。
    • getAccessibleContext

      public AccessibleContext  getAccessibleContext()
      获取与此 BasicComboPopup 关联的 AccessibleContext。 AccessibleContext 将其父级设置为 ComboBox。
      指定者:
      getAccessibleContext 在接口 Accessible
      重写:
      getAccessibleContext 在类 JPopupMenu
      返回:
      BasicComboPopup 的 AccessibleContext
      自从:
      1.5
    • delegateFocus

      protected void delegateFocus(MouseEvent  e)
      这是一个实用程序方法,可帮助事件处理程序确定弹出窗口出现时将焦点发送到何处。标准实现将焦点委托给编辑器(如果组合框可编辑)或 JComboBox(如果它不可编辑)。
      参数:
      e - 鼠标事件
    • togglePopup

      protected void togglePopup()
      如果弹出窗口隐藏则使其可见,如果弹出窗口可见则使其隐藏。
    • convertMouseEvent

      protected MouseEvent  convertMouseEvent(MouseEvent  e)
      转换鼠标事件。
      参数:
      e - 鼠标事件
      返回:
      转换鼠标事件
    • getPopupHeightForRowCount

      protected int getPopupHeightForRowCount(int maxRowCount)
      根据当前 ListCellRenderer 和最大行数检索弹出窗口的高度。
      参数:
      maxRowCount - 行数
      返回:
      弹出窗口的高度
    • computePopupBounds

      protected Rectangle  computePopupBounds(int px, int py, int pw, int ph)
      根据组合框位置和封闭屏幕边界计算组合框弹出部分的位置和大小。如果不需要转换,则返回的矩形将具有与参数相同的值。
      参数:
      px - 起始 x 位置
      py - 起始 y 位置
      pw - 起始宽度
      ph - 起始高度
      返回:
      代表弹出窗口位置和大小的矩形
    • updateListBoxSelectionForEvent

      protected void updateListBoxSelectionForEvent(MouseEvent  anEvent, boolean shouldScroll)
      事件监听使用的实用方法。给定鼠标事件,它将列表选择更改为鼠标下方的列表项。
      参数:
      anEvent - 鼠标事件
      shouldScroll - 如果应滚动 true 列表。