1 /* BasicComboPopup.java --
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.plaf
.basic
;
41 import java
.awt
.Color
;
42 import java
.awt
.Component
;
43 import java
.awt
.Dimension
;
44 import java
.awt
.Point
;
45 import java
.awt
.Rectangle
;
46 import java
.awt
.event
.ItemEvent
;
47 import java
.awt
.event
.ItemListener
;
48 import java
.awt
.event
.KeyAdapter
;
49 import java
.awt
.event
.KeyEvent
;
50 import java
.awt
.event
.KeyListener
;
51 import java
.awt
.event
.MouseAdapter
;
52 import java
.awt
.event
.MouseEvent
;
53 import java
.awt
.event
.MouseListener
;
54 import java
.awt
.event
.MouseMotionAdapter
;
55 import java
.awt
.event
.MouseMotionListener
;
56 import java
.beans
.PropertyChangeEvent
;
57 import java
.beans
.PropertyChangeListener
;
59 import javax
.swing
.BorderFactory
;
60 import javax
.swing
.ComboBoxModel
;
61 import javax
.swing
.JComboBox
;
62 import javax
.swing
.JLabel
;
63 import javax
.swing
.JList
;
64 import javax
.swing
.JPopupMenu
;
65 import javax
.swing
.JScrollBar
;
66 import javax
.swing
.JScrollPane
;
67 import javax
.swing
.ListCellRenderer
;
68 import javax
.swing
.ListSelectionModel
;
69 import javax
.swing
.SwingConstants
;
70 import javax
.swing
.SwingUtilities
;
71 import javax
.swing
.Timer
;
72 import javax
.swing
.UIManager
;
73 import javax
.swing
.event
.ListDataEvent
;
74 import javax
.swing
.event
.ListDataListener
;
75 import javax
.swing
.event
.ListSelectionEvent
;
76 import javax
.swing
.event
.ListSelectionListener
;
77 import javax
.swing
.event
.PopupMenuEvent
;
78 import javax
.swing
.event
.PopupMenuListener
;
81 * UI Delegate for ComboPopup
83 * @author Olga Rodimina
85 public class BasicComboPopup
extends JPopupMenu
implements ComboPopup
87 /* Timer for autoscrolling */
88 protected Timer autoscrollTimer
;
90 /** ComboBox associated with this popup */
91 protected JComboBox comboBox
;
93 /** FIXME: Need to document */
94 protected boolean hasEntered
;
97 * Indicates whether the scroll bar located in popup menu with comboBox's
98 * list of items is currently autoscrolling. This happens when mouse event
99 * originated in the combo box and is dragged outside of its bounds
101 protected boolean isAutoScrolling
;
103 /** ItemListener listening to the selection changes in the combo box */
104 protected ItemListener itemListener
;
106 /** This listener is not used */
107 protected KeyListener keyListener
;
109 /** JList which is used to display item is the combo box */
110 protected JList list
;
112 /** This listener is not used */
113 protected ListDataListener listDataListener
;
116 * MouseListener listening to mouse events occuring in the combo box's
119 protected MouseListener listMouseListener
;
122 * MouseMotionListener listening to mouse motion events occuring in the
125 protected MouseMotionListener listMouseMotionListener
;
127 /** This listener is not used */
128 protected ListSelectionListener listSelectionListener
;
130 /** MouseListener listening to mouse events occuring in the combo box */
131 protected MouseListener mouseListener
;
134 * MouseMotionListener listening to mouse motion events occuring in the
137 protected MouseMotionListener mouseMotionListener
;
140 * PropertyChangeListener listening to changes occuring in the bound
141 * properties of the combo box
143 protected PropertyChangeListener propertyChangeListener
;
145 /** direction for scrolling down list of combo box's items */
146 protected static final int SCROLL_DOWN
= 1;
148 /** direction for scrolling up list of combo box's items */
149 protected static final int SCROLL_UP
= 0;
151 /** Indicates auto scrolling direction */
152 protected int scrollDirection
;
154 /** JScrollPane that contains list portion of the combo box */
155 protected JScrollPane scroller
;
157 /** This field is not used */
158 protected boolean valueIsAdjusting
;
161 * Creates a new BasicComboPopup object.
163 * @param comboBox the combo box with which this popup should be associated
165 public BasicComboPopup(JComboBox comboBox
)
167 this.comboBox
= comboBox
;
168 installComboBoxListeners();
170 setLightWeightPopupEnabled(comboBox
.isLightWeightPopupEnabled());
174 * This method displays drow down list of combo box items on the screen.
178 Rectangle cbBounds
= comboBox
.getBounds();
180 // popup should have same width as the comboBox and should be hight anough
181 // to display number of rows equal to 'maximumRowCount' property
182 int popupHeight
= getPopupHeightForRowCount(comboBox
.getMaximumRowCount());
184 scroller
.setPreferredSize(new Dimension(cbBounds
.width
, popupHeight
));
187 // Highlight selected item in the combo box's drop down list
188 if (comboBox
.getSelectedIndex() != -1)
189 list
.setSelectedIndex(comboBox
.getSelectedIndex());
191 //scroll scrollbar s.t. selected item is visible
192 JScrollBar scrollbar
= scroller
.getVerticalScrollBar();
193 int selectedIndex
= comboBox
.getSelectedIndex();
194 if (selectedIndex
> comboBox
.getMaximumRowCount())
195 scrollbar
.setValue(getPopupHeightForRowCount(selectedIndex
));
197 // We put the autoclose-registration inside an InvocationEvent, so that
198 // the same event that triggered this show() call won't hide the popup
200 SwingUtilities
.invokeLater
205 // Register this popup to be autoclosed when user clicks outside the
207 BasicLookAndFeel laf
= (BasicLookAndFeel
) UIManager
.getLookAndFeel();
208 laf
.registerForAutoClose(BasicComboPopup
.this);
211 // location specified is relative to comboBox
212 super.show(comboBox
, 0, cbBounds
.height
);
217 * This method hides drop down list of items
221 super.setVisible(false);
225 * Return list cointaining JComboBox's items
227 * @return list cointaining JComboBox's items
229 public JList
getList()
235 * Returns MouseListener that is listening to mouse events occuring in the
238 * @return MouseListener
240 public MouseListener
getMouseListener()
242 return mouseListener
;
246 * Returns MouseMotionListener that is listening to mouse motion events
247 * occuring in the combo box.
249 * @return MouseMotionListener
251 public MouseMotionListener
getMouseMotionListener()
253 return mouseMotionListener
;
257 * Returns KeyListener listening to key events occuring in the combo box.
258 * This method returns null because KeyHandler is not longer used.
260 * @return KeyListener
262 public KeyListener
getKeyListener()
268 * This method uninstalls the UI for the given JComponent.
270 public void uninstallingUI()
272 uninstallComboBoxModelListeners(comboBox
.getModel());
274 uninstallListeners();
275 uninstallKeyboardActions();
279 * This method uninstalls listeners that were listening to changes occuring
280 * in the comb box's data model
282 * @param model data model for the combo box from which to uninstall
285 protected void uninstallComboBoxModelListeners(ComboBoxModel model
)
287 model
.removeListDataListener(listDataListener
);
291 * This method uninstalls keyboard actions installed by the UI.
293 protected void uninstallKeyboardActions()
295 // FIXME: Need to implement
299 * This method fires PopupMenuEvent indicating that combo box's popup list
300 * of items will become visible
302 protected void firePopupMenuWillBecomeVisible()
304 PopupMenuListener
[] ll
= comboBox
.getPopupMenuListeners();
306 for (int i
= 0; i
< ll
.length
; i
++)
307 ll
[i
].popupMenuWillBecomeVisible(new PopupMenuEvent(comboBox
));
311 * This method fires PopupMenuEvent indicating that combo box's popup list
312 * of items will become invisible.
314 protected void firePopupMenuWillBecomeInvisible()
316 PopupMenuListener
[] ll
= comboBox
.getPopupMenuListeners();
318 for (int i
= 0; i
< ll
.length
; i
++)
319 ll
[i
].popupMenuWillBecomeInvisible(new PopupMenuEvent(comboBox
));
323 * This method fires PopupMenuEvent indicating that combo box's popup list
324 * of items was closed without selection.
326 protected void firePopupMenuCanceled()
328 PopupMenuListener
[] ll
= comboBox
.getPopupMenuListeners();
330 for (int i
= 0; i
< ll
.length
; i
++)
331 ll
[i
].popupMenuCanceled(new PopupMenuEvent(comboBox
));
335 * Creates MouseListener to listen to mouse events occuring in the combo
336 * box. Note that this listener doesn't listen to mouse events occuring in
337 * the popup portion of the combo box, it only listens to main combo box
340 * @return new MouseMotionListener that listens to mouse events occuring in
343 protected MouseListener
createMouseListener()
345 return new InvocationMouseHandler();
349 * Create Mouse listener that listens to mouse dragging events occuring in
350 * the combo box. This listener is responsible for changing the selection
351 * in the combo box list to the component over which mouse is being
354 * @return new MouseMotionListener that listens to mouse dragging events
355 * occuring in the combo box
357 protected MouseMotionListener
createMouseMotionListener()
359 return new InvocationMouseMotionHandler();
363 * KeyListener created in this method is not used anymore.
365 * @return KeyListener that does nothing
367 protected KeyListener
createKeyListener()
369 return new InvocationKeyHandler();
373 * ListSelectionListener created in this method is not used anymore
375 * @return ListSelectionListener that does nothing
377 protected ListSelectionListener
createListSelectionListener()
379 return new ListSelectionHandler();
383 * Creates ListDataListener. This method returns null, because
384 * ListDataHandler class is obsolete and is no longer used.
388 protected ListDataListener
createListDataListener()
394 * This method creates ListMouseListener to listen to mouse events occuring
395 * in the combo box's item list.
397 * @return MouseListener to listen to mouse events occuring in the combo
400 protected MouseListener
createListMouseListener()
402 return new ListMouseHandler();
406 * Creates ListMouseMotionlistener to listen to mouse motion events occuring
407 * in the combo box's list. This listener is responsible for highlighting
408 * items in the list when mouse is moved over them.
410 * @return MouseMotionListener that handles mouse motion events occuring in
411 * the list of the combo box.
413 protected MouseMotionListener
createListMouseMotionListener()
415 return new ListMouseMotionHandler();
419 * Creates PropertyChangeListener to handle changes in the JComboBox's bound
422 * @return PropertyChangeListener to handle changes in the JComboBox's bound
425 protected PropertyChangeListener
createPropertyChangeListener()
427 return new PropertyChangeHandler();
431 * Creates new ItemListener that will listen to ItemEvents occuring in the
434 * @return ItemListener to listen to ItemEvents occuring in the combo box.
436 protected ItemListener
createItemListener()
438 return new ItemHandler();
442 * Creates JList that will be used to display items in the combo box.
444 * @return JList that will be used to display items in the combo box.
446 protected JList
createList()
448 JList l
= new JList(comboBox
.getModel());
449 l
.setSelectionMode(ListSelectionModel
.SINGLE_INTERVAL_SELECTION
);
454 * This method configures the list of comboBox's items by setting default
455 * properties and installing listeners.
457 protected void configureList()
459 list
.setModel(comboBox
.getModel());
460 list
.setVisibleRowCount(comboBox
.getMaximumRowCount());
461 list
.setFocusable(false);
462 installListListeners();
466 * This method installs list listeners.
468 protected void installListListeners()
470 // mouse listener listening to mouse events occuring in the
471 // combo box's list of items.
472 listMouseListener
= createListMouseListener();
473 list
.addMouseListener(listMouseListener
);
475 // mouse listener listening to mouse motion events occuring in the
476 // combo box's list of items
477 listMouseMotionListener
= createListMouseMotionListener();
478 list
.addMouseMotionListener(listMouseMotionListener
);
480 listSelectionListener
= createListSelectionListener();
481 list
.addListSelectionListener(listSelectionListener
);
485 * This method creates scroll pane that will contain the list of comboBox's
486 * items inside of it.
488 * @return JScrollPane
490 protected JScrollPane
createScroller()
492 return new JScrollPane();
496 * This method configures scroll pane to contain list of comboBox's items
498 protected void configureScroller()
500 scroller
.setBorder(null);
501 scroller
.getViewport().setView(list
);
502 scroller
.setHorizontalScrollBarPolicy(JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
506 * This method configures popup menu that will be used to display Scrollpane
507 * with list of items inside of it.
509 protected void configurePopup()
511 setBorder(BorderFactory
.createLineBorder(Color
.BLACK
));
512 // initialize list that will be used to display combo box's items
513 this.list
= createList();
514 ((JLabel
) list
.getCellRenderer()).setHorizontalAlignment(SwingConstants
.LEFT
);
517 // initialize scroller. Add list to the scroller.
518 scroller
= createScroller();
521 // add scroller with list inside of it to JPopupMenu
526 * This method installs listeners that will listen to changes occuring
529 protected void installComboBoxListeners()
531 // mouse listener that listens to mouse event in combo box
532 mouseListener
= createMouseListener();
533 comboBox
.addMouseListener(mouseListener
);
535 // mouse listener that listens to mouse dragging events in the combo box
536 mouseMotionListener
= createMouseMotionListener();
537 comboBox
.addMouseMotionListener(mouseMotionListener
);
539 // item listener listenening to selection events in the combo box
540 itemListener
= createItemListener();
541 comboBox
.addItemListener(itemListener
);
543 propertyChangeListener
= createPropertyChangeListener();
544 comboBox
.addPropertyChangeListener(propertyChangeListener
);
548 * This method installs listeners that will listen to changes occuring in
549 * the comb box's data model
551 * @param model data model for the combo box for which to install listeners
553 protected void installComboBoxModelListeners(ComboBoxModel model
)
555 // list data listener to listen for ListDataEvents in combo box.
556 // This listener is now obsolete and nothing is done here
557 listDataListener
= createListDataListener();
558 comboBox
.getModel().addListDataListener(listDataListener
);
564 protected void installKeyboardActions()
566 // FIXME: Need to implement
570 * This method always returns false to indicate that items in the combo box
571 * list are not focus traversable.
575 public boolean isFocusTraversable()
581 * This method start scrolling combo box's list of items either up or down
582 * depending on the specified 'direction'
584 * @param direction of the scrolling.
586 protected void startAutoScrolling(int direction
)
589 isAutoScrolling
= true;
591 if (direction
== SCROLL_UP
)
598 * This method stops scrolling the combo box's list of items
600 protected void stopAutoScrolling()
603 isAutoScrolling
= false;
607 * This method scrolls up list of combo box's items up and highlights that
608 * just became visible.
610 protected void autoScrollUp()
612 // scroll up the scroll bar to make the item above visible
613 JScrollBar scrollbar
= scroller
.getVerticalScrollBar();
614 int scrollToNext
= list
.getScrollableUnitIncrement(super.getBounds(),
615 SwingConstants
.VERTICAL
,
618 scrollbar
.setValue(scrollbar
.getValue() - scrollToNext
);
620 // If we haven't reached the begging of the combo box's list of items,
621 // then highlight next element above currently highlighted element
622 if (list
.getSelectedIndex() != 0)
623 list
.setSelectedIndex(list
.getSelectedIndex() - 1);
627 * This method scrolls down list of combo box's and highlights item in the
628 * list that just became visible.
630 protected void autoScrollDown()
632 // scroll scrollbar down to make next item visible
633 JScrollBar scrollbar
= scroller
.getVerticalScrollBar();
634 int scrollToNext
= list
.getScrollableUnitIncrement(super.getBounds(),
635 SwingConstants
.VERTICAL
,
637 scrollbar
.setValue(scrollbar
.getValue() + scrollToNext
);
639 // If we haven't reached the end of the combo box's list of items
640 // then highlight next element below currently highlighted element
641 if (list
.getSelectedIndex() + 1 != comboBox
.getItemCount())
642 list
.setSelectedIndex(list
.getSelectedIndex() + 1);
646 * This method helps to delegate focus to the right component in the
647 * JComboBox. If the comboBox is editable then focus is sent to
648 * ComboBoxEditor, otherwise it is delegated to JComboBox.
650 * @param e MouseEvent
652 protected void delegateFocus(MouseEvent e
)
654 // FIXME: Need to implement
658 * This method displays combo box popup if the popup is not currently shown
659 * on the screen and hides it if it is currently visible
661 protected void togglePopup()
663 if (BasicComboPopup
.this.isVisible())
672 * @param e DOCUMENT ME!
674 * @return DOCUMENT ME!
676 protected MouseEvent
convertMouseEvent(MouseEvent e
)
682 * Returns required height of the popup such that number of items visible in
683 * it are equal to the maximum row count. By default
684 * comboBox.maximumRowCount=8
686 * @param maxRowCount number of maximum visible rows in the combo box's
687 * popup list of items
689 * @return height of the popup required to fit number of items equal to
690 * JComboBox.maximumRowCount.
692 protected int getPopupHeightForRowCount(int maxRowCount
)
695 ListCellRenderer rend
= list
.getCellRenderer();
697 if (comboBox
.getItemCount() < maxRowCount
)
698 maxRowCount
= comboBox
.getItemCount();
700 for (int i
= 0; i
< maxRowCount
; i
++)
702 Component comp
= rend
.getListCellRendererComponent(list
,
706 Dimension dim
= comp
.getPreferredSize();
707 totalHeight
+= dim
.height
;
716 * @param px DOCUMENT ME!
717 * @param py DOCUMENT ME!
718 * @param pw DOCUMENT ME!
719 * @param ph DOCUMENT ME!
721 * @return DOCUMENT ME!
723 protected Rectangle
computePopupBounds(int px
, int py
, int pw
, int ph
)
725 return new Rectangle(px
, py
, pw
, ph
);
729 * This method changes the selection in the list to the item over which the
730 * mouse is currently located.
732 * @param anEvent MouseEvent
733 * @param shouldScroll DOCUMENT ME!
735 protected void updateListBoxSelectionForEvent(MouseEvent anEvent
,
736 boolean shouldScroll
)
738 // TODO: We need to handle the shouldScroll parameter somehow.
739 int index
= list
.locationToIndex(anEvent
.getPoint());
740 // Check for valid index.
742 list
.setSelectedIndex(index
);
746 * InvocationMouseHandler is a listener that listens to mouse events
747 * occuring in the combo box. Note that this listener doesn't listen to
748 * mouse events occuring in the popup portion of the combo box, it only
749 * listens to main combo box part(area that displays selected item). This
750 * listener is responsible for showing and hiding popup portion of the
753 protected class InvocationMouseHandler
extends MouseAdapter
756 * Creates a new InvocationMouseHandler object.
758 protected InvocationMouseHandler()
760 // Nothing to do here.
764 * This method is invoked whenever mouse is being pressed over the main
765 * part of the combo box. This method will show popup if the popup is
766 * not shown on the screen right now, and it will hide popup otherwise.
768 * @param e MouseEvent that should be handled
770 public void mousePressed(MouseEvent e
)
772 if (comboBox
.isEnabled())
777 * This method is invoked whenever mouse event was originated in the combo
778 * box and released either in the combBox list of items or in the combo
781 * @param e MouseEvent that should be handled
783 public void mouseReleased(MouseEvent e
)
785 // Get component over which mouse was released
786 Component src
= (Component
) e
.getSource();
789 Component releasedComponent
= SwingUtilities
.getDeepestComponentAt(src
,
792 // if mouse was released inside the bounds of combo box then do nothing,
793 // Otherwise if mouse was released inside the list of combo box items
794 // then change selection and close popup
795 if (! (releasedComponent
instanceof JComboBox
))
797 // List model contains the item over which mouse is released,
798 // since it is updated every time the mouse is moved over a different
799 // item in the list. Now that the mouse is released we need to
800 // update model of the combo box as well.
801 comboBox
.setSelectedIndex(list
.getSelectedIndex());
811 * InvocationMouseMotionListener is a mouse listener that listens to mouse
812 * dragging events occuring in the combo box.
814 protected class InvocationMouseMotionHandler
extends MouseMotionAdapter
817 * Creates a new InvocationMouseMotionHandler object.
819 protected InvocationMouseMotionHandler()
821 // Nothing to do here.
825 * This method is responsible for highlighting item in the drop down list
826 * over which the mouse is currently being dragged.
828 public void mouseDragged(MouseEvent e
)
830 // convert point of the drag event relative to combo box list component
831 // figure out over which list cell the mouse is currently being dragged
832 // and highlight the cell. The list model is changed but the change has
833 // no effect on combo box's data model. The list model is changed so
834 // that the appropriate item would be highlighted in the combo box's
836 if (BasicComboPopup
.this.isVisible())
838 int cbHeight
= (int) comboBox
.getPreferredSize().getHeight();
839 int popupHeight
= BasicComboPopup
.this.getSize().height
;
841 // if mouse is dragged inside the the combo box's items list.
842 if (e
.getY() > cbHeight
&& ! (e
.getY() - cbHeight
>= popupHeight
))
844 int index
= list
.locationToIndex(new Point(e
.getX(),
848 int firstVisibleIndex
= list
.getFirstVisibleIndex();
850 // list.locationToIndex returns item's index that would
851 // be located at the specified point if the first item that
852 // is visible is item 0. However in the JComboBox it is not
853 // necessarily the case since list is contained in the
854 // JScrollPane so we need to adjust the index returned.
855 if (firstVisibleIndex
!= 0)
856 // FIXME: adjusted index here is off by one. I am adding one
857 // here to compensate for that. This should be
858 // index += firstVisibleIndex. Remove +1 once the bug is fixed.
859 index
+= firstVisibleIndex
+ 1;
861 list
.setSelectedIndex(index
);
865 // if mouse is being dragged at the bottom of combo box's list
866 // of items or at the very top then scroll the list in the
867 // desired direction.
868 boolean movingUP
= e
.getY() < cbHeight
;
869 boolean movingDown
= e
.getY() > cbHeight
;
873 scrollDirection
= SCROLL_UP
;
874 startAutoScrolling(SCROLL_UP
);
878 scrollDirection
= SCROLL_DOWN
;
879 startAutoScrolling(SCROLL_DOWN
);
887 * ItemHandler is an item listener that listens to selection events occuring
888 * in the combo box. FIXME: should specify here what it does when item is
889 * selected or deselected in the combo box list.
891 protected class ItemHandler
extends Object
implements ItemListener
894 * Creates a new ItemHandler object.
896 protected ItemHandler()
898 // Nothing to do here.
902 * This method responds to the selection events occuring in the combo box.
904 * @param e ItemEvent specifying the combo box's selection
906 public void itemStateChanged(ItemEvent e
)
908 // TODO: What should be done here?
913 * ListMouseHandler is a listener that listens to mouse events occuring in
914 * the combo box's list of items. This class is responsible for hiding
915 * popup portion of the combo box if the mouse is released inside the combo
918 protected class ListMouseHandler
extends MouseAdapter
920 protected ListMouseHandler()
922 // Nothing to do here.
925 public void mousePressed(MouseEvent e
)
927 // TODO: What should be do here?
930 public void mouseReleased(MouseEvent anEvent
)
932 int index
= list
.locationToIndex(anEvent
.getPoint());
933 // Check for valid index.
935 comboBox
.setSelectedIndex(index
);
941 * ListMouseMotionHandler listens to mouse motion events occuring in the
942 * combo box's list. This class is responsible for highlighting items in
943 * the list when mouse is moved over them
945 protected class ListMouseMotionHandler
extends MouseMotionAdapter
947 protected ListMouseMotionHandler()
949 // Nothing to do here.
952 public void mouseMoved(MouseEvent anEvent
)
954 updateListBoxSelectionForEvent(anEvent
, false);
959 * This class listens to changes occuring in the bound properties of the
962 protected class PropertyChangeHandler
extends Object
963 implements PropertyChangeListener
965 protected PropertyChangeHandler()
967 // Nothing to do here.
970 public void propertyChange(PropertyChangeEvent e
)
972 if (e
.getPropertyName().equals("renderer"))
974 list
.setCellRenderer((ListCellRenderer
) e
.getNewValue());
978 if (e
.getPropertyName().equals("dataModel"))
980 list
.setModel((ComboBoxModel
) e
.getNewValue());
987 // ------ private helper methods --------------------
990 * This method uninstalls listeners installed by the UI
992 private void uninstallListeners()
994 uninstallListListeners();
995 uninstallComboBoxListeners();
996 uninstallComboBoxModelListeners(comboBox
.getModel());
1000 * This method uninstalls Listeners registered with combo boxes list of
1003 private void uninstallListListeners()
1005 list
.removeMouseListener(listMouseListener
);
1006 listMouseListener
= null;
1008 list
.removeMouseMotionListener(listMouseMotionListener
);
1009 listMouseMotionListener
= null;
1013 * This method uninstalls listeners listening to combo box associated with
1016 private void uninstallComboBoxListeners()
1018 comboBox
.removeMouseListener(mouseListener
);
1019 mouseListener
= null;
1021 comboBox
.removeMouseMotionListener(mouseMotionListener
);
1022 mouseMotionListener
= null;
1024 comboBox
.removeItemListener(itemListener
);
1025 itemListener
= null;
1027 comboBox
.removePropertyChangeListener(propertyChangeListener
);
1028 propertyChangeListener
= null;
1031 // --------------------------------------------------------------------
1032 // The following classes are here only for backwards API compatibility
1033 // They aren't used.
1034 // --------------------------------------------------------------------
1037 * This class is not used any more.
1039 public class ListDataHandler
extends Object
implements ListDataListener
1041 public ListDataHandler()
1043 // Nothing to do here.
1046 public void contentsChanged(ListDataEvent e
)
1048 // Nothing to do here.
1051 public void intervalAdded(ListDataEvent e
)
1053 // Nothing to do here.
1056 public void intervalRemoved(ListDataEvent e
)
1058 // Nothing to do here.
1063 * This class is not used anymore
1065 protected class ListSelectionHandler
extends Object
1066 implements ListSelectionListener
1068 protected ListSelectionHandler()
1070 // Nothing to do here.
1073 public void valueChanged(ListSelectionEvent e
)
1075 // Nothing to do here.
1080 * This class is not used anymore
1082 public class InvocationKeyHandler
extends KeyAdapter
1084 public InvocationKeyHandler()
1086 // Nothing to do here.
1089 public void keyReleased(KeyEvent e
)
1091 // Nothing to do here.