src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java

Print this page

        

*** 182,191 **** --- 182,193 ---- * * @see #createItemListener */ protected ItemListener itemListener; + private MouseWheelListener scrollerMouseWheelListener; + /** * This protected field is implementation specific. Do not access directly * or override. */ protected Timer autoscrollTimer;
*** 309,318 **** --- 311,321 ---- comboBox.removeItemListener( itemListener ); } uninstallComboBoxModelListeners(comboBox.getModel()); uninstallKeyboardActions(); uninstallListListeners(); + uninstallScrollerListeners(); // We do this, otherwise the listener the ui installs on // the model (the combobox model in this case) will keep a // reference to the list, causing the list (and us) to never get gced. list.setModel(EmptyListModel); }
*** 606,615 **** --- 609,619 ---- */ protected void configureScroller() { scroller.setFocusable( false ); scroller.getVerticalScrollBar().setFocusable( false ); scroller.setBorder( null ); + installScrollerListeners(); } /** * Configures the popup portion of the combo box. This method is called * when the UI class is created.
*** 622,631 **** --- 626,649 ---- add( scroller ); setDoubleBuffered( true ); setFocusable( false ); } + private void installScrollerListeners() { + scrollerMouseWheelListener = getHandler(); + if (scrollerMouseWheelListener != null) { + scroller.addMouseWheelListener(scrollerMouseWheelListener); + } + } + + private void uninstallScrollerListeners() { + if (scrollerMouseWheelListener != null) { + scroller.removeMouseWheelListener(scrollerMouseWheelListener); + scrollerMouseWheelListener = null; + } + } + /** * This method adds the necessary listeners to the JComboBox. */ protected void installComboBoxListeners() { if ((propertyChangeListener = createPropertyChangeListener()) != null) {
*** 833,844 **** } } private class Handler implements ItemListener, MouseListener, ! MouseMotionListener, PropertyChangeListener, ! Serializable { // // MouseListener // NOTE: this is added to both the JList and JComboBox // public void mouseClicked(MouseEvent e) { --- 851,862 ---- } } private class Handler implements ItemListener, MouseListener, ! MouseMotionListener, MouseWheelListener, ! PropertyChangeListener, Serializable { // // MouseListener // NOTE: this is added to both the JList and JComboBox // public void mouseClicked(MouseEvent e) {
*** 1022,1031 **** --- 1040,1056 ---- @SuppressWarnings("unchecked") JComboBox<Object> comboBox = (JComboBox)e.getSource(); setListSelection(comboBox.getSelectedIndex()); } } + + // + // MouseWheelListener + // + public void mouseWheelMoved(MouseWheelEvent e) { + e.consume(); + } } // // end Event Listeners //=================================================================