Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.plaf.basic
Class BasicComboPopup

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--javax.swing.JComponent
                        |
                        +--javax.swing.JPopupMenu
                              |
                              +--javax.swing.plaf.basic.BasicComboPopup

Direct Known Subclasses:
  MetalComboBoxUI.MetalComboPopup

public class BasicComboPopup
extends JPopupMenu
implements ComboPopup

This is an implementation of the ComboPopup interface. It is primarily for use by BasicComboBoxUI and its subclasses. BasicComboPopup extends JPopupMenu because most combo boxes use a popup menu to display the list of possible selections. BasicComboBoxUI only requires a ComboPopup, so subclasses of BasicComboBoxUI aren't required to use this class. All event handling is handled by 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. Inner classes for handling events: InvocationMouseHandler InvocationMouseMotionHandler InvocationKeyHandler ListSelectionHandler ListDataHandler ListMouseHandler ListMouseMotionHandler PropertyChangeHandler ItemHandler

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. A future release of Swing will provide support for long term persistence.

See Also:
  Serialized Form

Inner Class Summary
`class` | `BasicComboPopup.InvocationKeyHandler` This listener watches for the spacebar being pressed and shows/hides the popup accordingly.
`protected class` | `BasicComboPopup.InvocationMouseHandler` This listener knows how and when to invoke this 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 in the JComboBox's selection.
`class` | `BasicComboPopup.ListDataHandler` Keeps the selected index in the list in-sync with the combo box's selection.
`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` This listener watches for changes in the list's selection and reports them to the combo box.
`protected class` | `BasicComboPopup.PropertyChangeHandler` This listener watches for bound property changes in JComboBox.

Inner classes inherited from class javax.swing.JPopupMenu
`JPopupMenu.AccessibleJPopupMenu, JPopupMenu.Separator`

Inner classes inherited from class javax.swing.JComponent
`JComponent.AccessibleJComponent`

Field Summary
`protected Timer` | `autoscrollTimer`
`protected JComboBox` | `comboBox`
`protected boolean` | `hasEntered`
`protected boolean` | `isAutoScrolling`
`protected java.awt.event.ItemListener` | `itemListener`
`protected java.awt.event.KeyListener` | `keyListener`
`protected JList` | `list`
`protected ListDataListener` | `listDataListener`
`protected java.awt.event.MouseListener` | `listMouseListener`
`protected java.awt.event.MouseMotionListener` | `listMouseMotionListener`
`protected ListSelectionListener` | `listSelectionListener`
`protected java.awt.event.MouseListener` | `mouseListener`
`protected java.awt.event.MouseMotionListener` | `mouseMotionListener`
`protected java.beans.PropertyChangeListener` | `propertyChangeListener`
`protected static int` | `SCROLL_DOWN`
`protected static int` | `SCROLL_UP`
`protected int` | `scrollDirection`
`protected JScrollPane` | `scroller`
`protected boolean` | `valueIsAdjusting`

Fields inherited from class javax.swing.JComponent
`accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

Fields inherited from class java.awt.Component
`BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

Constructor Summary
`BasicComboPopup(JComboBox combo)`

Method Summary
`protected void` | `autoScrollDown()`
`protected void` | `autoScrollUp()`
`protected java.awt.Rectangle` | `computePopupBounds(int px, int py, int pw, int ph)`
`protected void` | `configureList()` Called to configure the list created by createList().
`protected void` | `configurePopup()` Called to configure this JPopupMenu (BasicComboPopup is a JPopupMenu).
`protected void` | `configureScroller()` Called to configure the JScrollPane created by createScroller().
`protected java.awt.event.MouseEvent` | `convertMouseEvent(java.awt.event.MouseEvent e)`
`protected java.awt.event.ItemListener` | `createItemListener()` Creates an item listener that watches for changes in the selected item in the JComboBox.
`protected java.awt.event.KeyListener` | `createKeyListener()` Creates the key listener that is returned by ComboPopup.getKeyListener().
`protected JList` | `createList()` Creates the JList that is used in the popup to display the items in the model.
`protected ListDataListener` | `createListDataListener()` Creates a list data listener that watches for inserted and removed items from the combo box model.
`protected java.awt.event.MouseListener` | `createListMouseListener()` Creates a mouse listener that watches for mouse events in the popup's list.
`protected java.awt.event.MouseMotionListener` | `createListMouseMotionListener()` Creates a mouse motion listener that watches for mouse events in the popup's list.
`protected ListSelectionListener` | `createListSelectionListener()` Creates a list selection listener that watches for selection changes in the popup's list.
`protected java.awt.event.MouseListener` | `createMouseListener()` Creates the mouse listener that is returned by ComboPopup.getMouseListener().
`protected java.awt.event.MouseMotionListener` | `createMouseMotionListener()` Creates the mouse motion listener that is returned by ComboPopup.getMouseMotionListener().
`protected java.beans.PropertyChangeListener` | `createPropertyChangeListener()` Creates a property change listener that watches for changes in the bound properties in the JComboBox.
`protected JScrollPane` | `createScroller()` Creates the JScrollPane that is used in the popup to hold the list.
`protected void` | `delegateFocus(java.awt.event.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.
`java.awt.event.KeyListener` | `getKeyListener()` Implementation of ComboPopup.getKeyListener().
`JList` | `getList()` Implementation of ComboPopup.getList().
`java.awt.event.MouseListener` | `getMouseListener()` Implementation of ComboPopup.getMouseListener().
`java.awt.event.MouseMotionListener` | `getMouseMotionListener()` Implementation of ComboPopup.getMouseMotionListener().
`protected int` | `getPopupHeightForRowCount(int maxRowCount)`
`void` | `hide()` Implementation of ComboPopup.hide().
`protected void` | `installComboBoxListeners()` This method adds the necessary listeners to the JComboBox.
`protected void` | `installComboBoxModelListeners(ComboBoxModel model)`
`protected void` | `installKeyboardActions()`
`protected void` | `installListListeners()` Called by configureList() to add the necessary listeners to the list.
`boolean` | `isFocusTraversable()` Overridden to unconditionally return false.
`void` | `show()` Implementation of ComboPopup.show().
`protected void` | `startAutoScrolling(int direction)` Called by BasicComboPopup$InvocationMouseMotionHandler to handle auto- scrolling the list.
`protected void` | `stopAutoScrolling()`
`protected void` | `togglePopup()` Makes the popup visible if it is hidden and makes it hidden if it is visible.
`protected void` | `uninstallComboBoxModelListeners(ComboBoxModel model)`
`void` | `uninstallingUI()` Called when the UI is uninstalling.
`protected void` | `uninstallKeyboardActions()`
`protected void` | `updateListBoxSelectionForEvent(java.awt.event.MouseEvent anEvent, boolean shouldScroll)` A utility method used by the event listeners.

Methods inherited from class javax.swing.JPopupMenu
`add, add, add, addPopupMenuListener, addSeparator, createActionChangeListener, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processKeyEvent, processMouseEvent, remove, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, updateUI`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setLayout, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, getBackground, getBounds, getColorModel, getCursor, getFont, getFontMetrics, getForeground, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isEnabled, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setLocale, setLocation, setName, setSize, setSize, show, size, toString, transferFocus`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### comboBox

    protected JComboBox comboBox

### list

    protected JList list

### scroller

    protected JScrollPane scroller

### valueIsAdjusting

    protected boolean valueIsAdjusting

### mouseMotionListener

    protected java.awt.event.MouseMotionListener mouseMotionListener

### mouseListener

    protected java.awt.event.MouseListener mouseListener

### keyListener

    protected java.awt.event.KeyListener keyListener

### listSelectionListener

    protected ListSelectionListener listSelectionListener

### listDataListener

    protected ListDataListener listDataListener

### listMouseListener

    protected java.awt.event.MouseListener listMouseListener

### listMouseMotionListener

    protected java.awt.event.MouseMotionListener listMouseMotionListener

### propertyChangeListener

    protected java.beans.PropertyChangeListener propertyChangeListener

### itemListener

    protected java.awt.event.ItemListener itemListener

### autoscrollTimer

    protected Timer autoscrollTimer

### hasEntered

    protected boolean hasEntered

### isAutoScrolling

    protected boolean isAutoScrolling

### scrollDirection

    protected int scrollDirection

### SCROLL_UP

    protected static final int SCROLL_UP

### SCROLL_DOWN

    protected static final int SCROLL_DOWN

Constructor Detail

### BasicComboPopup

    public BasicComboPopup(JComboBox combo)

Method Detail

### show

    public void show()

  Implementation of ComboPopup.show().
  Specified by:
    show in interface ComboPopup
  Overrides:
    show in class java.awt.Component

### hide

    public void hide()

  Implementation of ComboPopup.hide().
  Specified by:
    hide in interface ComboPopup
  Overrides:
    hide in class java.awt.Component

### getList

    public JList getList()

  Implementation of ComboPopup.getList().
  Specified by:
    getList in interface ComboPopup

### getMouseListener

    public java.awt.event.MouseListener getMouseListener()

  Implementation of ComboPopup.getMouseListener().
  Specified by:
    getMouseListener in interface ComboPopup

### getMouseMotionListener

    public java.awt.event.MouseMotionListener getMouseMotionListener()

  Implementation of ComboPopup.getMouseMotionListener().
  Specified by:
    getMouseMotionListener in interface ComboPopup

### getKeyListener

    public java.awt.event.KeyListener getKeyListener()

  Implementation of ComboPopup.getKeyListener().
  Specified by:
    getKeyListener in interface ComboPopup

### uninstallingUI

    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().
  Specified by:
    uninstallingUI in interface ComboPopup

### uninstallComboBoxModelListeners

    protected void uninstallComboBoxModelListeners(ComboBoxModel model)

### uninstallKeyboardActions

    protected void uninstallKeyboardActions()

### createMouseListener

    protected java.awt.event.MouseListener createMouseListener()

  Creates the mouse listener that is returned by ComboPopup.getMouseListener(). Returns an instance of BasicComboPopup$InvocationMouseHandler.

### createMouseMotionListener

    protected java.awt.event.MouseMotionListener createMouseMotionListener()

  Creates the mouse motion listener that is returned by ComboPopup.getMouseMotionListener(). Returns an instance of BasicComboPopup$InvocationMouseMotionListener.

### createKeyListener

    protected java.awt.event.KeyListener createKeyListener()

  Creates the key listener that is returned by ComboPopup.getKeyListener(). Returns an instance of BasicComboPopup$InvocationKeyHandler.

### createListSelectionListener

    protected ListSelectionListener createListSelectionListener()

  Creates a list selection listener that watches for selection changes in the popup's list. Returns an instance of BasicComboPopup$ListSelectionHandler.

### createListDataListener

    protected ListDataListener createListDataListener()

  Creates a list data listener that watches for inserted and removed items from the combo box model.

### createListMouseListener

    protected java.awt.event.MouseListener createListMouseListener()

  Creates a mouse listener that watches for mouse events in the popup's list. Returns an instance of BasicComboPopup$ListMouseHandler.

### createListMouseMotionListener

    protected java.awt.event.MouseMotionListener createListMouseMotionListener()

  Creates a mouse motion listener that watches for mouse events in the popup's list. Returns an instance of BasicComboPopup$ListMouseMotionHandler.

### createPropertyChangeListener

    protected java.beans.PropertyChangeListener createPropertyChangeListener()

  Creates a property change listener that watches for changes in the bound properties in the JComboBox. Returns an instance of BasicComboPopup$PropertyChangeHandler.

### createItemListener

    protected java.awt.event.ItemListener createItemListener()

  Creates an item listener that watches for changes in the selected item in the JComboBox. Returns an instance of BasicComboPopup$ItemHandler.

### createList

    protected JList createList()

  Creates the JList that is used in the popup to display the items in the model.

### configureList

    protected void configureList()

  Called to configure the list created by createList().

### installListListeners

    protected void installListListeners()

  Called by configureList() to add the necessary listeners to the list.

### createScroller

    protected JScrollPane createScroller()

  Creates the JScrollPane that is used in the popup to hold the list.

### configureScroller

    protected void configureScroller()

  Called to configure the JScrollPane created by createScroller().

### configurePopup

    protected void configurePopup()

  Called to configure this JPopupMenu (BasicComboPopup is a JPopupMenu).

### installComboBoxListeners

    protected void installComboBoxListeners()

  This method adds the necessary listeners to the JComboBox.

### installComboBoxModelListeners

    protected void installComboBoxModelListeners(ComboBoxModel model)

### installKeyboardActions

    protected void installKeyboardActions()

### isFocusTraversable

    public boolean isFocusTraversable()

  Overridden to unconditionally return false.
  Overrides:
    isFocusTraversable in class JComponent

### startAutoScrolling

    protected void startAutoScrolling(int direction)

  Called by BasicComboPopup$InvocationMouseMotionHandler to handle auto- scrolling the list.

### stopAutoScrolling

    protected void stopAutoScrolling()

### autoScrollUp

    protected void autoScrollUp()

### autoScrollDown

    protected void autoScrollDown()

### delegateFocus

    protected void delegateFocus(java.awt.event.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.

### togglePopup

    protected void togglePopup()

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

### convertMouseEvent

    protected java.awt.event.MouseEvent convertMouseEvent(java.awt.event.MouseEvent e)

### getPopupHeightForRowCount

    protected int getPopupHeightForRowCount(int maxRowCount)

### computePopupBounds

    protected java.awt.Rectangle computePopupBounds(int px,
                                                    int py,
                                                    int pw,
                                                    int ph)

### updateListBoxSelectionForEvent

    protected void updateListBoxSelectionForEvent(java.awt.event.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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.