APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicComboPopup

extends JPopupMenu
implements ComboPopup
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.basic.ComboPopup
Known Direct Subclasses
javax.swing.plaf.metal.MetalComboBoxUI.MetalComboPopup, javax.swing.plaf.synth.SynthComboPopup, com.sun.java.swing.plaf.motif.MotifComboBoxUI.MotifComboPopup
Annotations
@SuppressWarnings:serial
Imports
javax.accessibility.AccessibleContext, javax.swing.*, javax.swing.border.Border, .LineBorder, javax.swing.event.*, java.awt.*, java.awt.event.*, java.beans.PropertyChangeListener, .PropertyChangeEvent, java.io.Serializable, sun.awt.AWTAccessor, .AWTAccessor.MouseEventAccessor

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 JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Tom Santos, Mark Davidson

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
private class
public class
BasicComboPopup.InvocationKeyHandler

As of Java 2 platform v 1.4, this class is now obsolete and is only included for backwards API compatibility.

protected 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.

protected class
BasicComboPopup.InvocationMouseMotionHandler

This listener watches for dragging and updates the current selection in the list if it is dragging over the list.

protected class
BasicComboPopup.ItemHandler

This listener watches for changes to the selection in the combo box.

public class
BasicComboPopup.ListDataHandler

As of 1.4, this class is now obsolete, doesn't do anything, and is only included for backwards API compatibility.

protected class
BasicComboPopup.ListMouseHandler

This listener hides the popup when the mouse is released in the list.

protected class
BasicComboPopup.ListMouseMotionHandler

This listener changes the selected item as you move the mouse over the list.

protected 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.

protected class
BasicComboPopup.PropertyChangeHandler

This listener watches for bound properties that have changed in the combo box.

Field Summary

Modifier and TypeField and Description
protected Timer
autoscrollTimer

This protected field is implementation specific.

protected JComboBox<Object>
comboBox

The instance of JComboBox.

pack-priv static final ListModel<Object>
private BasicComboPopup.Handler
handler

Implementation of all the listener classes.

protected boolean
hasEntered

true if the mouse cursor is in the popup.

protected boolean
isAutoScrolling

If true the auto-scrolling is enabled.

protected ItemListener
itemListener

This protected field is implementation specific.

protected KeyListener
keyListener

Hides java.awt.Component.keyListener.

This protected field is implementation specific.
protected JList<Object>
list

This protected field is implementation specific.

private static Border
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

Hides java.awt.Component.mouseListener.

This protected field is implementation specific.
protected MouseMotionListener
mouseMotionListener

Hides java.awt.Component.mouseMotionListener.

This protected field is implementation specific.
protected PropertyChangeListener
propertyChangeListener

This protected field is implementation specific.

protected static final int
SCROLL_DOWN

The direction of scrolling down.

protected static final int
SCROLL_UP

The direction of scrolling up.

protected int
scrollDirection

The direction of scrolling.

protected JScrollPane
scroller

This protected field is implementation specific.

private MouseWheelListener
protected boolean
valueIsAdjusting

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

Constructor Summary

AccessConstructor and Description
public
BasicComboPopup(JComboBox<Object>
an instance of JComboBox
combo
)

Constructs a new instance of BasicComboPopup.

Method Summary

Modifier and TypeMethod and Description
protected void
autoScrollDown()

This protected method is implementation specific and should be private.

protected void
autoScrollUp()

This protected method is implementation specific and should be private.

protected Rectangle

Returns:

a rectangle which represents the placement and size of the popup
computePopupBounds
(int
starting x location
px
,
int
starting y location
py
,
int
starting width
pw
,
int
starting height
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.

protected void
configureList()

Configures the list which is used to hold the combo box items in the popup.

protected void
configurePopup()

Configures the popup portion of the combo box.

protected void
configureScroller()

Configures the scrollable portion which holds the list within the combo box popup.

protected MouseEvent

Returns:

converted mouse event
convertMouseEvent
(MouseEvent
a mouse event
e
)

Converts mouse event.

protected ItemListener

Returns:

an instance of an ItemListener or null
createItemListener
()

Creates an ItemListener which will be added to the combo box.

protected KeyListener

Returns:

a KeyListener or null
createKeyListener
()

Creates the key listener that will be added to the combo box.

protected JList<Object>

Returns:

a JList used to display the combo box items
createList
()

Creates the JList used in the popup to display the items in the combo box model.

protected ListDataListener

Returns:

an instance of a ListDataListener or null
createListDataListener
()

Creates a list data listener which will be added to the ComboBoxModel.

protected MouseListener

Returns:

an instance of a MouseListener or null
createListMouseListener
()

Creates a mouse listener that watches for mouse events in the popup's list.

protected MouseMotionListener

Returns:

an instance of a MouseMotionListener or null
createListMouseMotionListener
()

Creates a mouse motion listener that watches for mouse motion events in the popup's list.

protected ListSelectionListener

Returns:

an instance of a ListSelectionListener or null
createListSelectionListener
()

Creates a list selection listener that watches for selection changes in the popup's list.

protected MouseListener

Returns:

a MouseListener which will be added to the combo box or null
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.

protected MouseMotionListener

Returns:

a MouseMotionListener which will be added to the combo box or null
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.

protected PropertyChangeListener

Returns:

an instance of a PropertyChangeListener or null
createPropertyChangeListener
()

Creates a PropertyChangeListener which will be added to the combo box.

protected JScrollPane

Returns:

the scroll pane which houses the scrollable list
createScroller
()

Creates the scroll pane which houses the scrollable list.

protected void
delegateFocus(MouseEvent
a mouse event
e
)

This is a utility method that helps event handlers figure out where to send the focus when the popup is brought up.

protected void
firePopupMenuCanceled()

Overrides javax.swing.JPopupMenu.firePopupMenuCanceled.

Notifies PopupMenuListeners that this popup menu is cancelled.

protected void
firePopupMenuWillBecomeInvisible()

Overrides javax.swing.JPopupMenu.firePopupMenuWillBecomeInvisible.

Notifies PopupMenuListeners that this popup menu will become invisible.

protected void
firePopupMenuWillBecomeVisible()

Overrides javax.swing.JPopupMenu.firePopupMenuWillBecomeVisible.

Notifies PopupMenuListeners that this popup menu will become visible.

public AccessibleContext

Returns:

an AccessibleContext for the BasicComboPopup
getAccessibleContext
()

Overrides javax.swing.JPopupMenu.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this BasicComboPopup.

private BasicComboPopup.Handler
public KeyListener

Returns:

a KeyListener or null
getKeyListener
()

Implements javax.swing.plaf.basic.ComboPopup.getKeyListener.

Implementation of ComboPopup.getKeyListener().

public JList<Object>
getList()

Implements javax.swing.plaf.basic.ComboPopup.getList.

Implementation of ComboPopup.getList().

public MouseListener

Returns:

a MouseListener or null
getMouseListener
()

Implements javax.swing.plaf.basic.ComboPopup.getMouseListener.

Implementation of ComboPopup.getMouseListener().

public MouseMotionListener

Returns:

a MouseMotionListener or null
getMouseMotionListener
()

Implements javax.swing.plaf.basic.ComboPopup.getMouseMotionListener.

Implementation of ComboPopup.getMouseMotionListener().

protected int

Returns:

the height of the popup
getPopupHeightForRowCount
(int
the row count
maxRowCount
)

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

private Point
getPopupLocation()

Calculates the upper left location of the Popup.

public void
hide()

Overrides javax.swing.JComponent.hide.

Implements javax.swing.plaf.basic.ComboPopup.hide.

Implementation of ComboPopup.hide().

protected void
installComboBoxListeners()

This method adds the necessary listeners to the JComboBox.

protected void
installComboBoxModelListeners(ComboBoxModel<?>
The combo box model to install listeners
model
)

Installs the listeners on the combo box model.

protected void
installKeyboardActions()

Registers keyboard actions.

protected void
installListListeners()

Adds the listeners to the list control.

private void
public boolean
isFocusTraversable()

Overrides java.awt.Component.isFocusTraversable.

Overridden to unconditionally return false.

private void
setListSelection(int
the index to set the list
selectedIndex
)

Sets the list selection index to the selectedIndex.

public void
show()

Overrides java.awt.Component.show.

Implements javax.swing.plaf.basic.ComboPopup.show.

Implementation of ComboPopup.show().

protected void
startAutoScrolling(int
the direction of scrolling
direction
)

This protected method is implementation specific and should be private.

protected void
stopAutoScrolling()

This protected method is implementation specific and should be private.

protected void
togglePopup()

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

protected void
uninstallComboBoxModelListeners(ComboBoxModel<?>
The combo box model to install listeners
model
)

Removes the listeners from the combo box model

public void
uninstallingUI()

Implements javax.swing.plaf.basic.ComboPopup.uninstallingUI.

Called when the UI is uninstalling.

protected void
uninstallKeyboardActions()

Unregisters keyboard actions.

pack-priv void
private void
protected void
updateListBoxSelectionForEvent(MouseEvent
a mouse event
anEvent
,
boolean
if true list should be scrolled.
shouldScroll
)

A utility method used by the event listeners.

Inherited from javax.swing.JPopupMenu:
addaddaddaddMenuKeyListeneraddPopupMenuListeneraddSeparatorcreateActionChangeListenercreateActionComponentgetComponentgetComponentAtIndexgetComponentIndexgetDefaultLightWeightPopupEnabledgetInvokergetLabelgetMargingetMenuKeyListenersgetPopupMenuListenersgetSelectionModelgetSubElementsgetUIgetUIClassIDinsertinsertisBorderPaintedisLightWeightPopupEnabledisPopupTriggerisVisiblemenuSelectionChangedpackpaintBorderparamStringprocessFocusEventprocessKeyEventprocessKeyEventprocessMouseEventremoveremoveMenuKeyListenerremovePopupMenuListenersetBorderPaintedsetDefaultLightWeightPopupEnabledsetInvokersetLabelsetLightWeightPopupEnabledsetLocationsetPopupSizesetPopupSizesetSelectedsetSelectionModelsetUIsetVisibleshowupdateUI