public class

BasicComboPopup

extends JPopupMenu
implements ComboPopup
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ javax.swing.JPopupMenu
           ↳ javax.swing.plaf.basic.BasicComboPopup
Known Direct Subclasses

Class Overview

This is a basic implementation of the ComboPopup interface. This class represents the ui for the popup portion of the combo box.

All event handling is handled by listener classes created with the createxxxListener() methods and internal classes. You can change the behavior of this class by overriding the createxxxListener() methods and supplying your own event listeners or subclassing from the ones supplied in this class.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

Summary

Nested Classes
class BasicComboPopup.InvocationKeyHandler As of Java 2 platform v 1.4, this class is now obsolete and is only included for backwards API compatibility. 
class BasicComboPopup.InvocationMouseHandler A listener to be registered upon the combo box (not its popup menu) to handle mouse events that affect the state of the popup menu. 
class BasicComboPopup.InvocationMouseMotionHandler This listener watches for dragging and updates the current selection in the list if it is dragging over the list. 
class BasicComboPopup.ItemHandler This listener watches for changes to the selection in the combo box. 
class BasicComboPopup.ListDataHandler As of 1.4, this class is now obsolete, doesn't do anything, and is only included for backwards API compatibility. 
class BasicComboPopup.ListMouseHandler This listener hides the popup when the mouse is released in the list. 
class BasicComboPopup.ListMouseMotionHandler This listener changes the selected item as you move the mouse over the list. 
class BasicComboPopup.ListSelectionHandler As of Java 2 platform v 1.4, this class is now obsolete, doesn't do anything, and is only included for backwards API compatibility. 
class BasicComboPopup.PropertyChangeHandler This listener watches for bound properties that have changed in the combo box. 
Constants
int SCROLL_DOWN
int SCROLL_UP
[Expand]
Inherited Constants
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.image.ImageObserver
Fields
protected Timer autoscrollTimer This protected field is implementation specific.
protected JComboBox comboBox
protected boolean hasEntered
protected boolean isAutoScrolling
protected ItemListener itemListener This protected field is implementation specific.
protected KeyListener keyListener This protected field is implementation specific.
protected JList list This protected field is implementation specific.
protected ListDataListener listDataListener This protected field is implementation specific.
protected MouseListener listMouseListener This protected field is implementation specific.
protected MouseMotionListener listMouseMotionListener This protected field is implementation specific.
protected ListSelectionListener listSelectionListener This protected field is implementation specific.
protected MouseListener mouseListener This protected field is implementation specific.
protected MouseMotionListener mouseMotionListener This protected field is implementation specific.
protected PropertyChangeListener propertyChangeListener This protected field is implementation specific.
protected int scrollDirection
protected JScrollPane scroller This protected field is implementation specific.
protected boolean valueIsAdjusting As of Java 2 platform v1.4 this previously undocumented field is no longer used.
[Expand]
Inherited Fields
From class javax.swing.JComponent
Public Constructors
BasicComboPopup(JComboBox combo)
Public Methods
AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this BasicComboPopup.
KeyListener getKeyListener()
Implementation of ComboPopup.getKeyListener().
JList getList()
Implementation of ComboPopup.getList().
MouseListener getMouseListener()
Implementation of ComboPopup.getMouseListener().
MouseMotionListener getMouseMotionListener()
Implementation of ComboPopup.getMouseMotionListener().
void hide()
This method is deprecated. As of JDK version 1.1, replaced by setVisible(boolean).
boolean isFocusTraversable()
This method is deprecated. As of 1.4, replaced by isFocusable().
void show()
This method is deprecated. As of JDK version 1.1, replaced by setVisible(boolean).
void uninstallingUI()
Called when the UI is uninstalling.
Protected Methods
void autoScrollDown()
This protected method is implementation specific and should be private.
void autoScrollUp()
This protected method is implementation specific and should be private.
Rectangle computePopupBounds(int px, int py, int pw, int ph)
Calculate the placement and size of the popup portion of the combo box based on the combo box location and the enclosing screen bounds.
void configureList()
Configures the list which is used to hold the combo box items in the popup.
void configurePopup()
Configures the popup portion of the combo box.
void configureScroller()
Configures the scrollable portion which holds the list within the combo box popup.
MouseEvent convertMouseEvent(MouseEvent e)
ItemListener createItemListener()
Creates an ItemListener which will be added to the combo box.
KeyListener createKeyListener()
Creates the key listener that will be added to the combo box.
JList createList()
Creates the JList used in the popup to display the items in the combo box model.
ListDataListener createListDataListener()
Creates a list data listener which will be added to the ComboBoxModel.
MouseListener createListMouseListener()
Creates a mouse listener that watches for mouse events in the popup's list.
MouseMotionListener createListMouseMotionListener()
Creates a mouse motion listener that watches for mouse motion events in the popup's list.
ListSelectionListener createListSelectionListener()
Creates a list selection listener that watches for selection changes in the popup's list.
MouseListener createMouseListener()
Creates a listener that will watch for mouse-press and release events on the combo box.
MouseMotionListener createMouseMotionListener()
Creates the mouse motion listener which will be added to the combo box.
PropertyChangeListener createPropertyChangeListener()
Creates a PropertyChangeListener which will be added to the combo box.
JScrollPane createScroller()
Creates the scroll pane which houses the scrollable list.
void delegateFocus(MouseEvent e)
This is is a utility method that helps event handlers figure out where to send the focus when the popup is brought up.
void firePopupMenuCanceled()
Notifies PopupMenuListeners that this popup menu is cancelled.
void firePopupMenuWillBecomeInvisible()
Notifies PopupMenuListeners that this popup menu will become invisible.
void firePopupMenuWillBecomeVisible()
Notifies PopupMenuListeners that this popup menu will become visible.
int getPopupHeightForRowCount(int maxRowCount)
Retrieves the height of the popup based on the current ListCellRenderer and the maximum row count.
void installComboBoxListeners()
This method adds the necessary listeners to the JComboBox.
void installComboBoxModelListeners(ComboBoxModel model)
Installs the listeners on the combo box model.
void installKeyboardActions()
void installListListeners()
Adds the listeners to the list control.
void startAutoScrolling(int direction)
This protected method is implementation specific and should be private.
void stopAutoScrolling()
This protected method is implementation specific and should be private.
void togglePopup()
Makes the popup visible if it is hidden and makes it hidden if it is visible.
void uninstallComboBoxModelListeners(ComboBoxModel model)
Removes the listeners from the combo box model
void uninstallKeyboardActions()
void updateListBoxSelectionForEvent(MouseEvent anEvent, boolean shouldScroll)
A utility method used by the event listeners.
[Expand]
Inherited Methods
From class javax.swing.JPopupMenu
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface javax.accessibility.Accessible
From interface javax.swing.MenuElement
From interface javax.swing.plaf.basic.ComboPopup

Constants

protected static final int SCROLL_DOWN

Constant Value: 1 (0x00000001)

protected static final int SCROLL_UP

Constant Value: 0 (0x00000000)

Fields

protected Timer autoscrollTimer

This protected field is implementation specific. Do not access directly or override.

protected JComboBox comboBox

protected boolean hasEntered

protected boolean isAutoScrolling

protected ItemListener itemListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead

protected KeyListener keyListener

This protected field is implementation specific. Do not access directly or override. Use the accessor or create methods instead.

protected JList list

This protected field is implementation specific. Do not access directly or override. Use the accessor methods instead.

protected ListDataListener listDataListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead

protected MouseListener listMouseListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead.

protected MouseMotionListener listMouseMotionListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead

protected ListSelectionListener listSelectionListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead.

protected MouseListener mouseListener

This protected field is implementation specific. Do not access directly or override. Use the accessor or create methods instead.

protected MouseMotionListener mouseMotionListener

This protected field is implementation specific. Do not access directly or override. Use the accessor or create methods instead.

protected PropertyChangeListener propertyChangeListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead

protected int scrollDirection

protected JScrollPane scroller

This protected field is implementation specific. Do not access directly or override. Use the create method instead

See Also

protected boolean valueIsAdjusting

As of Java 2 platform v1.4 this previously undocumented field is no longer used.

Public Constructors

public BasicComboPopup (JComboBox combo)

Public Methods

public AccessibleContext getAccessibleContext ()

Gets the AccessibleContext associated with this BasicComboPopup. The AccessibleContext will have its parent set to the ComboBox.

Returns
  • an AccessibleContext for the BasicComboPopup

public KeyListener getKeyListener ()

Implementation of ComboPopup.getKeyListener().

Returns
  • a KeyListener or null
See Also

public JList getList ()

Implementation of ComboPopup.getList().

public MouseListener getMouseListener ()

Implementation of ComboPopup.getMouseListener().

Returns
  • a MouseListener or null

public MouseMotionListener getMouseMotionListener ()

Implementation of ComboPopup.getMouseMotionListener().

Returns
  • a MouseMotionListener or null

public void hide ()

This method is deprecated.
As of JDK version 1.1, replaced by setVisible(boolean).

Implementation of ComboPopup.hide().

public boolean isFocusTraversable ()

This method is deprecated.
As of 1.4, replaced by isFocusable().

Overridden to unconditionally return false.

Returns
  • true if this Component is focusable; false otherwise

public void show ()

This method is deprecated.
As of JDK version 1.1, replaced by setVisible(boolean).

Implementation of ComboPopup.show().

public void uninstallingUI ()

Called when the UI is uninstalling. Since this popup isn't in the component tree, it won't get it's uninstallUI() called. It removes the listeners that were added in addComboBoxListeners().

Protected Methods

protected void autoScrollDown ()

This protected method is implementation specific and should be private. do not call or override.

protected void autoScrollUp ()

This protected method is implementation specific and should be private. do not call or override.

protected Rectangle computePopupBounds (int px, int py, int pw, int ph)

Calculate the placement and size of the popup portion of the combo box based on the combo box location and the enclosing screen bounds. If no transformations are required, then the returned rectangle will have the same values as the parameters.

Parameters
px starting x location
py starting y location
pw starting width
ph starting height
Returns
  • a rectangle which represents the placement and size of the popup

protected void configureList ()

Configures the list which is used to hold the combo box items in the popup. This method is called when the UI class is created.

See Also

protected void configurePopup ()

Configures the popup portion of the combo box. This method is called when the UI class is created.

protected void configureScroller ()

Configures the scrollable portion which holds the list within the combo box popup. This method is called when the UI class is created.

protected MouseEvent convertMouseEvent (MouseEvent e)

protected ItemListener createItemListener ()

Creates an ItemListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

Subclasses may override this method to return instances of their own ItemEvent handlers.

Returns
  • an instance of an ItemListener or null

protected KeyListener createKeyListener ()

Creates the key listener that will be added to the combo box. If this method returns null then it will not be added to the combo box.

Returns
  • a KeyListener or null

protected JList createList ()

Creates the JList used in the popup to display the items in the combo box model. This method is called when the UI class is created.

Returns
  • a JList used to display the combo box items

protected ListDataListener createListDataListener ()

Creates a list data listener which will be added to the ComboBoxModel. If this method returns null then it will not be added to the combo box model.

Returns
  • an instance of a ListDataListener or null

protected MouseListener createListMouseListener ()

Creates a mouse listener that watches for mouse events in the popup's list. If this method returns null then it will not be added to the combo box.

Returns
  • an instance of a MouseListener or null

protected MouseMotionListener createListMouseMotionListener ()

Creates a mouse motion listener that watches for mouse motion events in the popup's list. If this method returns null then it will not be added to the combo box.

Returns
  • an instance of a MouseMotionListener or null

protected ListSelectionListener createListSelectionListener ()

Creates a list selection listener that watches for selection changes in the popup's list. If this method returns null then it will not be added to the popup list.

Returns
  • an instance of a ListSelectionListener or null

protected MouseListener createMouseListener ()

Creates a listener that will watch for mouse-press and release events on the combo box. Warning: When overriding this method, make sure to maintain the existing behavior.

Returns
  • a MouseListener which will be added to the combo box or null

protected MouseMotionListener createMouseMotionListener ()

Creates the mouse motion listener which will be added to the combo box. Warning: When overriding this method, make sure to maintain the existing behavior.

Returns
  • a MouseMotionListener which will be added to the combo box or null

protected PropertyChangeListener createPropertyChangeListener ()

Creates a PropertyChangeListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

Returns
  • an instance of a PropertyChangeListener or null

protected JScrollPane createScroller ()

Creates the scroll pane which houses the scrollable list.

protected void delegateFocus (MouseEvent e)

This is is a utility method that helps event handlers figure out where to send the focus when the popup is brought up. The standard implementation delegates the focus to the editor (if the combo box is editable) or to the JComboBox if it is not editable.

protected void firePopupMenuCanceled ()

Notifies PopupMenuListeners that this popup menu is cancelled.

protected void firePopupMenuWillBecomeInvisible ()

Notifies PopupMenuListeners that this popup menu will become invisible.

protected void firePopupMenuWillBecomeVisible ()

Notifies PopupMenuListeners that this popup menu will become visible.

protected int getPopupHeightForRowCount (int maxRowCount)

Retrieves the height of the popup based on the current ListCellRenderer and the maximum row count.

protected void installComboBoxListeners ()

This method adds the necessary listeners to the JComboBox.

protected void installComboBoxModelListeners (ComboBoxModel model)

Installs the listeners on the combo box model. Any listeners installed on the combo box model should be removed in uninstallComboBoxModelListeners.

Parameters
model The combo box model to install listeners

protected void installKeyboardActions ()

protected void installListListeners ()

Adds the listeners to the list control.

protected void startAutoScrolling (int direction)

This protected method is implementation specific and should be private. do not call or override.

protected void stopAutoScrolling ()

This protected method is implementation specific and should be private. do not call or override.

protected void togglePopup ()

Makes the popup visible if it is hidden and makes it hidden if it is visible.

protected void uninstallComboBoxModelListeners (ComboBoxModel model)

Removes the listeners from the combo box model

Parameters
model The combo box model to install listeners

protected void uninstallKeyboardActions ()

protected void updateListBoxSelectionForEvent (MouseEvent anEvent, boolean shouldScroll)

A utility method used by the event listeners. Given a mouse event, it changes the list selection to the list item below the mouse.