/[classpath]/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicComboBoxUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5.2.7 by gnu_andrew, Tue Aug 2 20:12:37 2005 UTC revision 1.5.2.8 by gnu_andrew, Tue Sep 20 18:46:33 2005 UTC
# Line 42  import java.awt.Color; Line 42  import java.awt.Color;
42  import java.awt.Component;  import java.awt.Component;
43  import java.awt.Container;  import java.awt.Container;
44  import java.awt.Dimension;  import java.awt.Dimension;
45    import java.awt.Font;
46  import java.awt.Graphics;  import java.awt.Graphics;
47  import java.awt.Insets;  import java.awt.Insets;
48  import java.awt.LayoutManager;  import java.awt.LayoutManager;
# Line 69  import javax.swing.JComboBox; Line 70  import javax.swing.JComboBox;
70  import javax.swing.JComponent;  import javax.swing.JComponent;
71  import javax.swing.JList;  import javax.swing.JList;
72  import javax.swing.ListCellRenderer;  import javax.swing.ListCellRenderer;
73    import javax.swing.SwingUtilities;
74  import javax.swing.UIDefaults;  import javax.swing.UIDefaults;
75  import javax.swing.UIManager;  import javax.swing.UIManager;
76  import javax.swing.event.ListDataEvent;  import javax.swing.event.ListDataEvent;
77  import javax.swing.event.ListDataListener;  import javax.swing.event.ListDataListener;
78  import javax.swing.plaf.ComboBoxUI;  import javax.swing.plaf.ComboBoxUI;
79  import javax.swing.plaf.ComponentUI;  import javax.swing.plaf.ComponentUI;
80    import javax.swing.plaf.UIResource;
81    
82  /**  /**
83   * UI Delegate for JComboBox   * A UI delegate for the {@link JComboBox} component.
84   *   *
85   * @author Olga Rodimina   * @author Olga Rodimina
86   * @author Robert Schuster   * @author Robert Schuster
# Line 85  import javax.swing.plaf.ComponentUI; Line 88  import javax.swing.plaf.ComponentUI;
88  public class BasicComboBoxUI extends ComboBoxUI  public class BasicComboBoxUI extends ComboBoxUI
89  {  {
90    /**    /**
91     * This arrow button that is displayed in the rigth side of JComboBox. This     * The arrow button that is displayed in the right side of JComboBox. This
92     * button is used to hide and show combo box's list of items     * button is used to hide and show combo box's list of items.
93     */     */
94    protected JButton arrowButton;    protected JButton arrowButton;
95    
96    /**    /**
97     * The combo box for which this UI delegate is for     * The combo box represented by this UI delegate.
98     */     */
99    protected JComboBox comboBox;    protected JComboBox comboBox;
100    
101    /**    /**
102     * Component that is responsible for displaying/editting  selected item of     * The component that is responsible for displaying/editing the selected
103     * the combo box. By default JTextField is used as an editor for the     * item of the combo box.
104     * JComboBox     *
105       * @see BasicComboBoxEditor#getEditorComponent()
106     */     */
107    protected Component editor;    protected Component editor;
108    
109    /**    /**
110     * Listener listening to focus events occuring in the JComboBox     * A listener listening to focus events occurring in the {@link JComboBox}.
111     */     */
112    protected FocusListener focusListener;    protected FocusListener focusListener;
113    
114    /**    /**
115     * tells whether JComboBox currently has focus     * A flag indicating whether JComboBox currently has the focus.
116     */     */
117    protected boolean hasFocus;    protected boolean hasFocus;
118    
119    /**    /**
120     * Listener listening to item events fired by the JComboBox     * A listener listening to item events fired by the {@link JComboBox}.
121     */     */
122    protected ItemListener itemListener;    protected ItemListener itemListener;
123    
124    /**    /**
125     * KeyListener listening to key events that occur while JComboBox has focus     * A listener listening to key events that occur while {@link JComboBox} has
126       * the focus.
127     */     */
128    protected KeyListener keyListener;    protected KeyListener keyListener;
129    
130    /**    /**
131     * MouseListener listening to mouse events occuring in the combo box     * A listener listening to mouse events occuring in the {@link JComboBox}.
132     */     */
133    private MouseListener mouseListener;    private MouseListener mouseListener;
134    
135    /**    /**
136     * List used when rendering selected item of the combo box. The selection     * List used when rendering selected item of the combo box. The selection
137     * and foreground colors for combo box renderer  are configured from this     * and foreground colors for combo box renderer are configured from this
138     * list     * list.
139     */     */
140    protected JList listBox;    protected JList listBox;
141    
# Line 140  public class BasicComboBoxUI extends Com Line 145  public class BasicComboBoxUI extends Com
145    protected ListDataListener listDataListener;    protected ListDataListener listDataListener;
146    
147    /**    /**
148     * Popup list containing combo box's menu items     * Popup list containing the combo box's menu items.
149     */     */
150    protected ComboPopup popup;    protected ComboPopup popup;
151    protected KeyListener popupKeyListener;    protected KeyListener popupKeyListener;
# Line 158  public class BasicComboBoxUI extends Com Line 163  public class BasicComboBoxUI extends Com
163    private Color shadow;    private Color shadow;
164    private Color darkShadow;    private Color darkShadow;
165    private Color highlight;    private Color highlight;
   private Color lightHighlight;  
166    
167    /* Size of the largest item in the comboBox    /* Size of the largest item in the comboBox
168     * This is package-private to avoid an accessor method.     * This is package-private to avoid an accessor method.
169     */     */
170    Dimension largestItemSize;    Dimension displaySize;
   
   // It seems that JComboBox doesn't have a border set explicitely. So we just  
   // paint the border everytime combo box is displayed.  
   
   /* border insets for this JComboBox  
    * This is package-private to avoid an accessor method. */  
   static final Insets borderInsets = new Insets(2, 2, 2, 2);  
   
   // Width of the arrow button    
   // This is package-private to avoid an accessor method.  
   // FIXME: has wrong name for a constant.  
   static final int arrowButtonWidth = 15;  
171    
172    // FIXME: This fields aren't used anywhere at this moment.    // FIXME: This fields aren't used anywhere at this moment.
173    protected Dimension cachedMinimumSize;    protected Dimension cachedMinimumSize;
# Line 183  public class BasicComboBoxUI extends Com Line 175  public class BasicComboBoxUI extends Com
175    protected boolean isMinimumSizeDirty;    protected boolean isMinimumSizeDirty;
176    
177    /**    /**
178     * Creates a new BasicComboBoxUI object.     * Creates a new <code>BasicComboBoxUI</code> object.
179     */     */
180    public BasicComboBoxUI()    public BasicComboBoxUI()
181    {    {
182    }    }
183    
184    /**    /**
185     * Factory method to create a BasicComboBoxUI for the given {@link     * A factory method to create a UI delegate for the given
186     * JComponent}, which should be a {@link JComboBox}.     * {@link JComponent}, which should be a {@link JComboBox}.
187     *     *
188     * @param c The {@link JComponent} a UI is being created for.     * @param c The {@link JComponent} a UI is being created for.
189     *     *
190     * @return A BasicComboBoxUI for the {@link JComponent}.     * @return A UI delegate for the {@link JComponent}.
191     */     */
192    public static ComponentUI createUI(JComponent c)    public static ComponentUI createUI(JComponent c)
193    {    {
# Line 203  public class BasicComboBoxUI extends Com Line 195  public class BasicComboBoxUI extends Com
195    }    }
196    
197    /**    /**
198     * This method installs the UI for the given JComponent.     * Installs the UI for the given {@link JComponent}.
199     *     *
200     * @param c The JComponent to install a UI for.     * @param c  the JComponent to install a UI for.
201       *
202       * @see #uninstallUI(JComponent)
203     */     */
204    public void installUI(JComponent c)    public void installUI(JComponent c)
205    {    {
# Line 224  public class BasicComboBoxUI extends Com Line 218  public class BasicComboBoxUI extends Com
218    }    }
219    
220    /**    /**
221     * This method uninstalls the UI.     * Uninstalls the UI for the given {@link JComponent}.
222     *     *
223     * @param c The JComponent that is having this UI removed.     * @param c The JComponent that is having this UI removed.
224       *
225       * @see #installUI(JComponent)
226     */     */
227    public void uninstallUI(JComponent c)    public void uninstallUI(JComponent c)
228    {    {
# Line 238  public class BasicComboBoxUI extends Com Line 234  public class BasicComboBoxUI extends Com
234    }    }
235    
236    /**    /**
237     * This method installs the defaults that are defined in  the Basic look and     * Installs the defaults that are defined in the {@link BasicLookAndFeel}
238     * feel for this {@link JComboBox}.     * for this {@link JComboBox}.
239       *
240       * @see #uninstallDefaults()
241     */     */
242    protected void installDefaults()    protected void installDefaults()
243    {    {
244      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
245    
246      comboBox.setBackground(defaults.getColor("ComboBox.background"));      if (comboBox.getFont() instanceof UIResource)
247      comboBox.setFont(defaults.getFont("ComboBox.font"));        comboBox.setFont(defaults.getFont("ComboBox.font"));
248      comboBox.setForeground(defaults.getColor("ComboBox.foreground"));      
249        if (comboBox.getForeground() instanceof UIResource)
250          comboBox.setForeground(defaults.getColor("ComboBox.foreground"));
251    
252        if (comboBox.getBackground() instanceof UIResource)
253          comboBox.setBackground(defaults.getColor("ComboBox.background"));
254    
255      // Set default color that should be used to to render selected item      // fetch the button color scheme
256      // of the combo box.      shadow = defaults.getColor("ComboBox.buttonShadow");
257      shadow = defaults.getColor("Button.shadow");      darkShadow = defaults.getColor("ComboBox.buttonDarkShadow");
258      darkShadow = defaults.getColor("Button.darkShadow");      highlight = defaults.getColor("ComboBox.buttonHighlight");
     lightHighlight = defaults.getColor("Button.light");  
     highlight = defaults.getColor("Button.highlight");  
259    }    }
260    
261    /**    /**
262     * This method creates and installs the listeners for this UI.     * Creates and installs the listeners for this UI.
263       *
264       * @see #uninstallListeners()
265     */     */
266    protected void installListeners()    protected void installListeners()
267    {    {
# Line 276  public class BasicComboBoxUI extends Com Line 279  public class BasicComboBoxUI extends Com
279      comboBox.addKeyListener(keyListener);      comboBox.addKeyListener(keyListener);
280    
281      mouseListener = createMouseListener();      mouseListener = createMouseListener();
282      comboBox.addMouseListener(mouseListener);      arrowButton.addMouseListener(mouseListener);
283    
284      // install listeners that listen to combo box model      // install listeners that listen to combo box model
285      listDataListener = createListDataListener();      listDataListener = createListDataListener();
286      comboBox.getModel().addListDataListener(listDataListener);      comboBox.getModel().addListDataListener(listDataListener);
   
     configureArrowButton();  
287    }    }
288    
289    /**    /**
290     * This method uninstalls the defaults and sets any objects created during     * Uninstalls the defaults and sets any objects created during
291     * install to null     * install to <code>null</code>.
292       *
293       * @see #installDefaults()
294     */     */
295    protected void uninstallDefaults()    protected void uninstallDefaults()
296    {    {
297      UIDefaults defaults = UIManager.getLookAndFeelDefaults();      if (comboBox.getFont() instanceof UIResource)
298          comboBox.setFont(null);
299    
300      comboBox.setBackground(null);      if (comboBox.getForeground() instanceof UIResource)
301      comboBox.setFont(null);        comboBox.setForeground(null);
302      comboBox.setForeground(null);      
303        if (comboBox.getBackground() instanceof UIResource)
304          comboBox.setBackground(null);
305    
306      shadow = null;      shadow = null;
307      darkShadow = null;      darkShadow = null;
     lightHighlight = null;  
308      highlight = null;      highlight = null;
309    }    }
310    
311    /**    /**
312     * Detaches all the listeners we attached in {@link #installListeners}.     * Detaches all the listeners we attached in {@link #installListeners}.
313       *
314       * @see #installListeners()
315     */     */
316    protected void uninstallListeners()    protected void uninstallListeners()
317    {    {
# Line 320  public class BasicComboBoxUI extends Com Line 327  public class BasicComboBoxUI extends Com
327      comboBox.removeKeyListener(keyListener);      comboBox.removeKeyListener(keyListener);
328      keyListener = null;      keyListener = null;
329    
330      comboBox.removeMouseListener(mouseListener);      arrowButton.removeMouseListener(mouseListener);
331      mouseListener = null;      mouseListener = null;
332    
333      comboBox.getModel().removeListDataListener(listDataListener);      comboBox.getModel().removeListDataListener(listDataListener);
334      listDataListener = null;      listDataListener = null;
   
     unconfigureArrowButton();  
335    }    }
336    
337    /**    /**
338     * This method creates popup that will contain list of combo box's items     * Creates the popup that will contain list of combo box's items.
339     *     *
340     * @return popup containing list of combo box's items     * @return popup containing list of combo box's items
341     */     */
# Line 340  public class BasicComboBoxUI extends Com Line 345  public class BasicComboBoxUI extends Com
345    }    }
346    
347    /**    /**
348     * Creates KeyListener to listen to key events.     * Creates a {@link KeyListener} to listen to key events.
349     *     *
350     * @return KeyListener that listens to key events.     * @return KeyListener that listens to key events.
351     */     */
# Line 350  public class BasicComboBoxUI extends Com Line 355  public class BasicComboBoxUI extends Com
355    }    }
356    
357    /**    /**
358     * This method create MouseListener that will listen to mouse event occuring     * Creates a {@link MouseListener} that will listen to mouse events occurring
359     * in combo box.     * in the combo box.
360     *     *
361     * @return the MouseListener     * @return the MouseListener
362     */     */
# Line 361  public class BasicComboBoxUI extends Com Line 366  public class BasicComboBoxUI extends Com
366    }    }
367    
368    /**    /**
369     * This method create FocusListener that will listen to changes in this     * Creates the {@link FocusListener} that will listen to changes in this
370     * JComboBox's focus.     * JComboBox's focus.
371     *     *
372     * @return theFocusListener     * @return the FocusListener.
373     */     */
374    protected FocusListener createFocusListener()    protected FocusListener createFocusListener()
375    {    {
# Line 372  public class BasicComboBoxUI extends Com Line 377  public class BasicComboBoxUI extends Com
377    }    }
378    
379    /**    /**
380     * This method create ListDataListener to listen to ComboBox's  data model     * Creates a {@link ListDataListener} to listen to the combo box's data model.
381     *     *
382     * @return ListDataListener     * @return The new listener.
383     */     */
384    protected ListDataListener createListDataListener()    protected ListDataListener createListDataListener()
385    {    {
# Line 382  public class BasicComboBoxUI extends Com Line 387  public class BasicComboBoxUI extends Com
387    }    }
388    
389    /**    /**
390     * This method creates ItemListener that will listen to to the changes in     * Creates an {@link ItemListener} that will listen to the changes in
391     * the JComboBox's selection.     * the JComboBox's selection.
392     *     *
393     * @return the ItemListener     * @return The ItemListener
394     */     */
395    protected ItemListener createItemListener()    protected ItemListener createItemListener()
396    {    {
# Line 393  public class BasicComboBoxUI extends Com Line 398  public class BasicComboBoxUI extends Com
398    }    }
399    
400    /**    /**
401     * This method creates PropertyChangeListener to listen to  the changes in     * Creates a {@link PropertyChangeListener} to listen to the changes in
402     * the JComboBox's bound properties.     * the JComboBox's bound properties.
403     *     *
404     * @return the PropertyChangeListener     * @return The PropertyChangeListener
405     */     */
406    protected PropertyChangeListener createPropertyChangeListener()    protected PropertyChangeListener createPropertyChangeListener()
407    {    {
# Line 404  public class BasicComboBoxUI extends Com Line 409  public class BasicComboBoxUI extends Com
409    }    }
410    
411    /**    /**
412     * This method returns layout manager for the combo box.     * Creates and returns a layout manager for the combo box.  Subclasses can
413       * override this method to provide a different layout.
414     *     *
415     * @return layout manager for the combo box     * @return a layout manager for the combo box.
416     */     */
417    protected LayoutManager createLayoutManager()    protected LayoutManager createLayoutManager()
418    {    {
# Line 414  public class BasicComboBoxUI extends Com Line 420  public class BasicComboBoxUI extends Com
420    }    }
421    
422    /**    /**
423     * This method creates component that will be responsible for rendering the     * Creates a component that will be responsible for rendering the
424     * selected component in the combo box.     * selected component in the combo box.
425     *     *
426     * @return render for the combo box     * @return A renderer for the combo box.
427     */     */
428    protected ListCellRenderer createRenderer()    protected ListCellRenderer createRenderer()
429    {    {
# Line 425  public class BasicComboBoxUI extends Com Line 431  public class BasicComboBoxUI extends Com
431    }    }
432    
433    /**    /**
434     * Creates component that will be responsible for displaying/editting     * Creates the component that will be responsible for displaying/editing
435     * selected item in the combo box. This editor is used only when combo box     * the selected item in the combo box. This editor is used only when combo
436     * is editable.     * box is editable.
437     *     *
438     * @return component that will be responsible for  displaying/editting     * @return A new component that will be responsible for displaying/editing
439     *         selected item in the combo box.     *         the selected item in the combo box.
440     */     */
441    protected ComboBoxEditor createEditor()    protected ComboBoxEditor createEditor()
442    {    {
# Line 438  public class BasicComboBoxUI extends Com Line 444  public class BasicComboBoxUI extends Com
444    }    }
445    
446    /**    /**
447     * This method installs components for this JComboBox. ArrowButton, main     * Installs the components for this JComboBox. ArrowButton, main
448     * part of combo box (upper part) and  popup list of items are created and     * part of combo box (upper part) and popup list of items are created and
449     * configured here.     * configured here.
450     */     */
451    protected void installComponents()    protected void installComponents()
452    {    {
453      // create and install arrow button      // create and install arrow button
454      arrowButton = createArrowButton();      arrowButton = createArrowButton();
455        configureArrowButton();
456      comboBox.add(arrowButton);      comboBox.add(arrowButton);
457    
458      // Set list that will be used by BasicComboBoxRender      // Set list that will be used by BasicComboBoxRender
459      // in order to determine the right colors when rendering      // in order to determine the right colors when rendering
460      listBox = new JList();      listBox = new JList();
461    
     Color background = arrowButton.getBackground();  
     listBox.setBackground(background);  
     listBox.setSelectionBackground(background.darker());  
   
     Color foreground = arrowButton.getForeground();  
     listBox.setForeground(foreground);  
     listBox.setSelectionForeground(foreground);  
   
462      // set editor and renderer for the combo box. Editor is used      // set editor and renderer for the combo box. Editor is used
463      // only if combo box becomes editable, otherwise renderer is used      // only if combo box becomes editable, otherwise renderer is used
464      // to paint the selected item; combobox is not editable by default.      // to paint the selected item; combobox is not editable by default.
# Line 476  public class BasicComboBoxUI extends Com Line 474  public class BasicComboBoxUI extends Com
474    }    }
475    
476    /**    /**
477     * This method uninstalls components from this JComboBox     * Uninstalls components from this {@link JComboBox}.
478       *
479       * @see #installComponents()
480     */     */
481    protected void uninstallComponents()    protected void uninstallComponents()
482    {    {
# Line 495  public class BasicComboBoxUI extends Com Line 495  public class BasicComboBoxUI extends Com
495    }    }
496    
497    /**    /**
498     * This method adds editor to the combo box     * Adds the current editor to the combo box.
499     */     */
500    public void addEditor()    public void addEditor()
501    {    {
# Line 503  public class BasicComboBoxUI extends Com Line 503  public class BasicComboBoxUI extends Com
503    }    }
504    
505    /**    /**
506     * This method removes editor from the combo box     * Removes the current editor from the combo box.
507     */     */
508    public void removeEditor()    public void removeEditor()
509    {    {
# Line 511  public class BasicComboBoxUI extends Com Line 511  public class BasicComboBoxUI extends Com
511    }    }
512    
513    /**    /**
514     * This method configures editor for this combo box.     * Configures the editor for this combo box.
515     */     */
516    protected void configureEditor()    protected void configureEditor()
517    {    {
518        editor.setFont(comboBox.getFont());
519        comboBox.getEditor().setItem(comboBox.getSelectedItem());
520      // FIXME: Need to implement. Set font and add listeners.      // FIXME: Need to implement. Set font and add listeners.
521    }    }
522    
523    /**    /**
524     * This method removes all the listeners for the editor.     * Unconfigures the editor for this combo nox.  This method is not implemented.
525     */     */
526    protected void unconfigureEditor()    protected void unconfigureEditor()
527    {    {
# Line 527  public class BasicComboBoxUI extends Com Line 529  public class BasicComboBoxUI extends Com
529    }    }
530    
531    /**    /**
532     * This method adds listeners to the arrow button part of the combo box.     * Configures the arrow button.
533       *
534       * @see #configureArrowButton()
535     */     */
536    public void configureArrowButton()    public void configureArrowButton()
537    {    {
538      arrowButton.addMouseListener(mouseListener);      arrowButton.setEnabled(comboBox.isEnabled());
539        arrowButton.setFont(comboBox.getFont());
540        arrowButton.setMargin(new Insets(0, 0, 0, 0));
541    }    }
542    
543    /**    /**
544     * This method removes listeners from the arrow button part of the combo     * Unconfigures the arrow button.
545     * box.     *
546       * @see #configureArrowButton()
547     */     */
548    public void unconfigureArrowButton()    public void unconfigureArrowButton()
549    {    {
     arrowButton.removeMouseListener(mouseListener);  
550    }    }
551    
552    /**    /**
553     * This method create arrow button for this JComboBox. Arrow button is     * Creates an arrow button for this {@link JComboBox}.  The arrow button is
554     * responsible for displaying / hiding drop down list of items  when it is     * displayed at the right end of the combo box and is used to display/hide
555     * clicked.     * the drop down list of items.
556     *     *
557     * @return JButton arrow button for this JComboBox.     * @return A new button.
558     */     */
559    protected JButton createArrowButton()    protected JButton createArrowButton()
560    {    {
# Line 556  public class BasicComboBoxUI extends Com Line 562  public class BasicComboBoxUI extends Com
562    }    }
563    
564    /**    /**
565     * This method checks if popup part of the combo box is visible on the     * Returns <code>true</code> if the popup is visible, and <code>false</code>
566     * screen     * otherwise.
567     *     *
568     * @param c The JComboBox to check     * @param c The JComboBox to check
569     *     *
570     * @return true if popup part of the JComboBox is visible and false     * @return <code>true</code> if popup part of the JComboBox is visible and
571     *         otherwise.     *         <code>false</code> otherwise.
572     */     */
573    public boolean isPopupVisible(JComboBox c)    public boolean isPopupVisible(JComboBox c)
574    {    {
# Line 570  public class BasicComboBoxUI extends Com Line 576  public class BasicComboBoxUI extends Com
576    }    }
577    
578    /**    /**
579     * Displays/Hides JComboBox's list of items on the screen.     * Displays/hides the {@link JComboBox}'s list of items on the screen.
580     *     *
581     * @param c The combo box, for which list of items should be     * @param c The combo box, for which list of items should be
582     *        displayed/hidden     *        displayed/hidden
# Line 593  public class BasicComboBoxUI extends Com Line 599  public class BasicComboBoxUI extends Com
599     */     */
600    public boolean isFocusTraversable(JComboBox c)    public boolean isFocusTraversable(JComboBox c)
601    {    {
602      if (comboBox.isEditable())      if (!comboBox.isEditable())
603        return true;        return true;
604    
605      return false;      return false;
# Line 607  public class BasicComboBoxUI extends Com Line 613  public class BasicComboBoxUI extends Com
613     */     */
614    public void paint(Graphics g, JComponent c)    public void paint(Graphics g, JComponent c)
615    {    {
616      if (c instanceof JComboBox)      Rectangle rect = rectangleForCurrentValue();
617        {      paintCurrentValueBackground(g, rect, hasFocus);
618          JComboBox cb = (JComboBox) c;      paintCurrentValue(g, rect, hasFocus);
   
         paintBorder(g, comboBox.getBounds(), hasFocus);  
   
         Rectangle rect = rectangleForCurrentValue();  
         paintCurrentValueBackground(g, rect, hasFocus);  
         paintCurrentValue(g, rect, hasFocus);  
       }  
   }  
   
   private void paintBorder(Graphics g, Rectangle bounds, boolean hasFocus)  
   {  
     int x = 0;  
     int y = 0;  
     int width = bounds.width;  
     int height = bounds.height;  
   
     Color oldColor = g.getColor();  
   
     if (! arrowButton.getModel().isPressed())  
       BasicGraphicsUtils.drawEtchedRect(g, x, y, width, height, Color.gray,  
                                         Color.white, Color.gray, Color.white);  
     else  
       {  
         g.setColor(darkShadow);  
         g.drawRect(x, y, width, height);  
         g.setColor(shadow);  
         g.drawRect(x + 1, y + 1, width - 3, height - 3);  
       }  
     g.setColor(oldColor);  
619    }    }
620    
621    /**    /**
622     * Returns preferred size for the given menu item.     * Returns preferred size for the combo box.
623     *     *
624     * @param c comboBox for which to get preferred size     * @param c comboBox for which to get preferred size
625     *     *
626     * @return $Dimension$ preferred size for the given combo box     * @return The preferred size for the given combo box
627     */     */
628    public Dimension getPreferredSize(JComponent c)    public Dimension getPreferredSize(JComponent c)
629    {    {
630      // return null to indicate that combo box's layout will determin its      return getMinimumSize(c);
     // preferred size  
     return null;  
631    }    }
632    
633    /**    /**
634     * This method returns the minimum size for this {@link JComboBox} for this     * Returns the minimum size for this {@link JComboBox} for this
635     * look and feel.     * look and feel.
636     *     *
637     * @param c The {@link JComponent} to find the minimum size for.     * @param c The {@link JComponent} to find the minimum size for.
# Line 665  public class BasicComboBoxUI extends Com Line 640  public class BasicComboBoxUI extends Com
640     */     */
641    public Dimension getMinimumSize(JComponent c)    public Dimension getMinimumSize(JComponent c)
642    {    {
643      return null;      Dimension d = getDisplaySize();
644        Dimension arrowDim = arrowButton.getPreferredSize();
645        Dimension result = new Dimension(d.width + arrowDim.width,
646                Math.max(d.height, arrowDim.height));
647        return result;
648    }    }
649    
650      /** The value returned by the getMaximumSize() method. */
651      private static final Dimension MAXIMUM_SIZE = new Dimension(32767, 32767);
652      
653    /**    /**
654     * This method returns the maximum size for this {@link JComboBox} for this     * Returns the maximum size for this {@link JComboBox} for this
655     * look and feel.     * look and feel.
656     *     *
657     * @param c The {@link JComponent} to find the maximum size for     * @param c The {@link JComponent} to find the maximum size for
# Line 678  public class BasicComboBoxUI extends Com Line 660  public class BasicComboBoxUI extends Com
660     */     */
661    public Dimension getMaximumSize(JComponent c)    public Dimension getMaximumSize(JComponent c)
662    {    {
663      return null;      return MAXIMUM_SIZE;
664    }    }
665    
666    public int getAccessibleChildrenCount(JComponent c)    public int getAccessibleChildrenCount(JComponent c)
# Line 707  public class BasicComboBoxUI extends Com Line 689  public class BasicComboBoxUI extends Com
689    }    }
690    
691    /**    /**
692     * This method selects next possible item relative to the current selection     * Selects next possible item relative to the current selection
693     * to be next selected item in the combo box.     * to be next selected item in the combo box.
694     */     */
695    protected void selectNextPossibleValue()    protected void selectNextPossibleValue()
# Line 718  public class BasicComboBoxUI extends Com Line 700  public class BasicComboBoxUI extends Com
700    }    }
701    
702    /**    /**
703     * This method selects previous item relative to current selection to be     * Selects previous item relative to current selection to be
704     * next selected item.     * next selected item.
705     */     */
706    protected void selectPreviousPossibleValue()    protected void selectPreviousPossibleValue()
# Line 729  public class BasicComboBoxUI extends Com Line 711  public class BasicComboBoxUI extends Com
711    }    }
712    
713    /**    /**
714     * This method displays combo box popup if the popup is not currently shown     * Displays combo box popup if the popup is not currently shown
715     * on the screen and hides it if it is  currently shown     * on the screen and hides it if it is currently shown
716     */     */
717    protected void toggleOpenClose()    protected void toggleOpenClose()
718    {    {
# Line 738  public class BasicComboBoxUI extends Com Line 720  public class BasicComboBoxUI extends Com
720    }    }
721    
722    /**    /**
723     * This method returns bounds in which comboBox's selected Item will be     * Returns the bounds in which comboBox's selected item will be
724     * displayed     * displayed.
725     *     *
726     * @return rectangle bounds in which comboBox's selected Item will be     * @return rectangle bounds in which comboBox's selected Item will be
727     *         displayed     *         displayed
728     */     */
729    protected Rectangle rectangleForCurrentValue()    protected Rectangle rectangleForCurrentValue()
730    {    {
731      Rectangle cbBounds = comboBox.getBounds();      Rectangle cbBounds = SwingUtilities.getLocalBounds(comboBox);
732        Rectangle abBounds = arrowButton.getBounds();  
733      // Subtract width or the arrow button and border insets              Rectangle rectForCurrentValue = new Rectangle(cbBounds.x, cbBounds.y,
734      Rectangle rectForCurrentValue = new Rectangle(cbBounds.x        cbBounds.width - abBounds.width, cbBounds.height);
                                                   + borderInsets.left,  
                                                   cbBounds.y  
                                                   + borderInsets.top,  
                                                   cbBounds.width  
                                                   - arrowButtonWidth  
                                                   - borderInsets.left  
                                                   - borderInsets.right,  
                                                   cbBounds.height  
                                                   - borderInsets.top  
                                                   - borderInsets.bottom);  
   
735      return rectForCurrentValue;      return rectForCurrentValue;
736    }    }
737    
738    /**    /**
739     * This method returns insets of the current border.     * Returns the insets of the current border.
740     *     *
741     * @return Insets representing space between combo box and its border     * @return Insets representing space between combo box and its border
742     */     */
# Line 775  public class BasicComboBoxUI extends Com Line 746  public class BasicComboBoxUI extends Com
746    }    }
747    
748    /**    /**
749     * This method paints currently selected value in the main part of the combo     * Paints currently selected value in the main part of the combo
750     * box (part without popup).     * box (part without popup).
751     *     *
752     * @param g graphics context     * @param g graphics context
# Line 794  public class BasicComboBoxUI extends Com Line 765  public class BasicComboBoxUI extends Com
765           * If there is currently no selected item we will take an empty           * If there is currently no selected item we will take an empty
766           * String as replacement.           * String as replacement.
767           */           */
768          Component comp = comboBox.getRenderer()          Component comp = comboBox.getRenderer().getListCellRendererComponent(
769                                       .getListCellRendererComponent(listBox,                  listBox, (currentValue != null ? currentValue : ""), -1,
770                                                                     (currentValue != null ? currentValue : ""),                  isPressed, hasFocus);
771                                                                     -1,          if (! comboBox.isEnabled())
772                                                                     isPressed,            {
773                                                                     hasFocus);              comp.setBackground(UIManager.getLookAndFeelDefaults().getColor(
774          if (! comboBox.isEnabled())                  "ComboBox.disabledBackground"));
775                comp.setEnabled(false);              comp.setForeground(UIManager.getLookAndFeelDefaults().getColor(
776                    "ComboBox.disabledForeground"));
777          g.translate(borderInsets.left, borderInsets.top);              comp.setEnabled(false);
778              comp.setBounds(0, 0, bounds.width, bounds.height);            }
779              comp.paint(g);          comp.setBounds(0, 0, bounds.width, bounds.height);
780              g.translate(-borderInsets.left, -borderInsets.top);          comp.setFont(comboBox.getFont());
781                        comp.paint(g);
782          comboBox.revalidate();          
783            comboBox.revalidate();
784        }        }
785      else      else
786        comboBox.getEditor().setItem(comboBox.getSelectedItem());        comboBox.getEditor().setItem(comboBox.getSelectedItem());
787    }    }
788    
789    /**    /**
790     * This method paints background of part of the combo box, where currently     * Paints the background of part of the combo box, where currently
791     * selected value is displayed. If the combo box has focus this method     * selected value is displayed. If the combo box has focus this method
792     * should also paint focus rectangle around the combo box.     * should also paint focus rectangle around the combo box.
793     *     *
# Line 839  public class BasicComboBoxUI extends Com Line 811  public class BasicComboBoxUI extends Com
811     */     */
812    protected Dimension getDefaultSize()    protected Dimension getDefaultSize()
813    {    {
814      return new Dimension(6, 17);      // FIXME: Not implemented properly.
815        return new Dimension(100, 5);
816    }    }
817    
818    /**    /**
# Line 848  public class BasicComboBoxUI extends Com Line 821  public class BasicComboBoxUI extends Com
821     *     *
822     * @return dimensions of the largest item in the combo box.     * @return dimensions of the largest item in the combo box.
823     */     */
824    protected Dimension getLargestItemSize()    protected Dimension getDisplaySize()
825    {    {
826      ComboBoxModel model = comboBox.getModel();      ComboBoxModel model = comboBox.getModel();
827      int numItems = model.getSize();      int numItems = model.getSize();
# Line 857  public class BasicComboBoxUI extends Com Line 830  public class BasicComboBoxUI extends Com
830      // return its default size      // return its default size
831      if (numItems == 0)      if (numItems == 0)
832        {        {
833          largestItemSize = getDefaultSize();          displaySize = getDefaultSize();
834          return largestItemSize;          return displaySize;
835        }        }
836    
837      Dimension size = new Dimension(0, 0);      Dimension size = new Dimension(0, 0);
# Line 867  public class BasicComboBoxUI extends Com Line 840  public class BasicComboBoxUI extends Com
840      // size of the largest item in the combo box.      // size of the largest item in the combo box.
841      ListCellRenderer renderer = comboBox.getRenderer();      ListCellRenderer renderer = comboBox.getRenderer();
842    
843        // FIXME: use the JComboBox.getPrototypeDisplayValue() if there is
844        // one
845      for (int i = 0; i < numItems; i++)      for (int i = 0; i < numItems; i++)
846        {        {
847          Object item = model.getElementAt(i);          Object item = model.getElementAt(i);
848          String s = item.toString();          String s = item.toString();
849          Component comp = renderer.getListCellRendererComponent(listBox, item,          Component comp = renderer.getListCellRendererComponent(listBox, item,
850                                                                 -1, false, false);              -1, false, false);
851    
852          if (comp.getPreferredSize().getWidth() > size.getWidth())          Dimension compSize = comp.getPreferredSize();
853            size = comp.getPreferredSize();          if (compSize.width > size.width)
854              size.width = compSize.width;
855            if (compSize.height > size.height)
856              size.height = compSize.height;
857        }        }
858        displaySize = size;
859      largestItemSize = size;      return displaySize;
     return largestItemSize;  
860    }    }
861    
862    /**    /**
863     * This method installs the keyboard actions for the JComboBox as specified     * Installs the keyboard actions for the {@link JComboBox} as specified
864     * by the look and feel.     * by the look and feel.
865     */     */
866    protected void installKeyboardActions()    protected void installKeyboardActions()
# Line 892  public class BasicComboBoxUI extends Com Line 869  public class BasicComboBoxUI extends Com
869    }    }
870    
871    /**    /**
872     * This method uninstalls the keyboard actions for the JComboBox there were     * Uninstalls the keyboard actions for the {@link JComboBox} there were
873     * installed by in {@link #installListeners}.     * installed by in {@link #installListeners}.
874     */     */
875    protected void uninstallKeyboardActions()    protected void uninstallKeyboardActions()
# Line 901  public class BasicComboBoxUI extends Com Line 878  public class BasicComboBoxUI extends Com
878    }    }
879    
880    /**    /**
881     * This class is Layout Manager for this combo box.     * A {@link LayoutManager} used to position the sub-components of the
882       * {@link JComboBox}.
883       *
884       * @see BasicComboBoxUI#createLayoutManager()
885     */     */
886    public class ComboBoxLayoutManager extends Object implements LayoutManager    public class ComboBoxLayoutManager implements LayoutManager
887    {    {
888      /**      /**
889       * Creates a new ComboBoxLayoutManager object.       * Creates a new ComboBoxLayoutManager object.
# Line 912  public class BasicComboBoxUI extends Com Line 892  public class BasicComboBoxUI extends Com
892      {      {
893      }      }
894    
895        /**
896         * Adds a component to the layout.  This method does nothing, since the
897         * layout manager doesn't need to track the components.
898         *
899         * @param name  the name to associate the component with (ignored).
900         * @param comp  the component (ignored).
901         */
902      public void addLayoutComponent(String name, Component comp)      public void addLayoutComponent(String name, Component comp)
903      {      {
904        // Do nothing        // Do nothing
905      }      }
906    
907        /**
908         * Removes a component from the layout.  This method does nothing, since
909         * the layout manager doesn't need to track the components.
910         *
911         * @param comp  the component.
912         */
913      public void removeLayoutComponent(Component comp)      public void removeLayoutComponent(Component comp)
914      {      {
915        // Do nothing        // Do nothing
# Line 925  public class BasicComboBoxUI extends Com Line 918  public class BasicComboBoxUI extends Com
918      /**      /**
919       * Returns preferred layout size of the JComboBox.       * Returns preferred layout size of the JComboBox.
920       *       *
921       * @param parent Container for which preferred size should be calculated       * @param parent  the Container for which the preferred size should be
922         *                calculated.
923       *       *
924       * @return preferred size for the given container       * @return The preferred size for the given container
925       */       */
926      public Dimension preferredLayoutSize(Container parent)      public Dimension preferredLayoutSize(Container parent)
927      {      {
928        Dimension d = new Dimension(0, 0);        return getPreferredSize((JComponent) parent);
   
       if (largestItemSize == null)  
         largestItemSize = getLargestItemSize();  
   
       // add size for the area that will display selected item  
       d.width += largestItemSize.getWidth();  
       d.height += largestItemSize.getHeight();  
   
       // add size of the arrow button  
       d.width += arrowButtonWidth;  
   
       // add width and height of the border  
       d.width += borderInsets.left + borderInsets.right;  
       d.height += borderInsets.left + borderInsets.right;  
   
       // Add combo box's insets          
       Insets insets = parent.getInsets();  
       d.width += insets.left + insets.right;  
       d.width += insets.left + insets.right;  
   
       return d;  
929      }      }
930    
931        /**
932         * Returns the minimum layout size.
933         *
934         * @param parent  the container.
935         *
936         * @return The minimum size.
937         */
938      public Dimension minimumLayoutSize(Container parent)      public Dimension minimumLayoutSize(Container parent)
939      {      {
940        return preferredLayoutSize(parent);        return preferredLayoutSize(parent);
941      }      }
942    
943      /**      /**
944       * This method layouts out the components in the container.  It puts arrow       * Arranges the components in the container.  It puts arrow
945       * button right end part of the comboBox. If the comboBox is editable       * button right end part of the comboBox. If the comboBox is editable
946       * then editor is placed to the left of arrow  button, starting from the       * then editor is placed to the left of arrow  button, starting from the
947       * beginning.       * beginning.
# Line 972  public class BasicComboBoxUI extends Com Line 952  public class BasicComboBoxUI extends Com
952      {      {
953        // Position editor component to the left of arrow button if combo box is        // Position editor component to the left of arrow button if combo box is
954        // editable        // editable
955        int editorWidth = comboBox.getBounds().width - arrowButtonWidth - 2;        int arrowSize = comboBox.getHeight();
956          int editorWidth = comboBox.getBounds().width - arrowSize;
957    
958        if (comboBox.isEditable())        if (comboBox.isEditable())
959          editor.setBounds(borderInsets.left, borderInsets.top, editorWidth,          editor.setBounds(0, 0, editorWidth, comboBox.getBounds().height);
960                           comboBox.getBounds().height - borderInsets.left        
961                           - borderInsets.top);        arrowButton.setBounds(editorWidth, 0, arrowSize, arrowSize);
   
       arrowButton.setBounds(editorWidth, 2, arrowButtonWidth,  
                             comboBox.getBounds().height - 4);  
962        comboBox.revalidate();        comboBox.revalidate();
963      }      }
964    }    }
965    
966    /**    /**
967     * This class handles focus changes occuring in the combo box. This class is     * Handles focus changes occuring in the combo box. This class is
968     * responsible for repainting combo box whenever focus is gained or lost     * responsible for repainting combo box whenever focus is gained or lost
969     * and also for hiding popup list of items whenever combo box loses its     * and also for hiding popup list of items whenever combo box loses its
970     * focus.     * focus.
# Line 1001  public class BasicComboBoxUI extends Com Line 979  public class BasicComboBoxUI extends Com
979      }      }
980    
981      /**      /**
982       * This mehtod is invoked when combo box gains focus. It repaints main       * Invoked when combo box gains focus. It repaints main
983       * part of combo box  accordingally.       * part of combo box accordingly.
984       *       *
985       * @param e the FocusEvent       * @param e the FocusEvent
986       */       */
# Line 1013  public class BasicComboBoxUI extends Com Line 991  public class BasicComboBoxUI extends Com
991      }      }
992    
993      /**      /**
994       * This method is invoked when combo box loses focus It repaint main part       * Invoked when the combo box loses focus.  It repaints the main part
995       * of combo box accordingally and  hides popup list of items.       * of the combo box accordingly and hides the popup list of items.
996       *       *
997       * @param e the FocusEvent       * @param e the FocusEvent
998       */       */
# Line 1022  public class BasicComboBoxUI extends Com Line 1000  public class BasicComboBoxUI extends Com
1000      {      {
1001        hasFocus = false;        hasFocus = false;
1002        comboBox.repaint();        comboBox.repaint();
       popup.hide();  
1003      }      }
1004    }    }
1005    
1006    /**    /**
1007     * This class handles ItemEvent fired by the JComboBox when its selected     * Handles {@link ItemEvent}s fired by the {@link JComboBox} when its
1008     * item changes.     * selected item changes.
1009     */     */
1010    public class ItemHandler extends Object implements ItemListener    public class ItemHandler extends Object implements ItemListener
1011    {    {
# Line 1040  public class BasicComboBoxUI extends Com Line 1017  public class BasicComboBoxUI extends Com
1017      }      }
1018    
1019      /**      /**
1020       * This method is invoked when selected item becomes deselected or when       * Invoked when selected item becomes deselected or when
1021       * new item becomes selected.       * new item becomes selected.
1022       *       *
1023       * @param e the ItemEvent representing item's state change.       * @param e the ItemEvent representing item's state change.
# Line 1060  public class BasicComboBoxUI extends Com Line 1037  public class BasicComboBoxUI extends Com
1037      {      {
1038      }      }
1039    
1040      /*      /**
1041       * This method is invoked whenever key is pressed while JComboBox is in       * Invoked whenever key is pressed while JComboBox is in focus.
      * focus.  
1042       */       */
1043      public void keyPressed(KeyEvent e)      public void keyPressed(KeyEvent e)
1044      {      {
# Line 1072  public class BasicComboBoxUI extends Com Line 1048  public class BasicComboBoxUI extends Com
1048    }    }
1049    
1050    /**    /**
1051     * This class handles to the changes occuring in the JComboBox's data model     * Handles the changes occurring in the JComboBox's data model.
1052     */     */
1053    public class ListDataHandler extends Object implements ListDataListener    public class ListDataHandler extends Object implements ListDataListener
1054    {    {
# Line 1084  public class BasicComboBoxUI extends Com Line 1060  public class BasicComboBoxUI extends Com
1060      }      }
1061    
1062      /**      /**
1063       * This method is invoked content's of JComboBox's data model  are changed       * Invoked if the content's of JComboBox's data model are changed.
1064       *       *
1065       * @param e ListDataEvent describing the change.       * @param e ListDataEvent describing the change.
1066       */       */
# Line 1094  public class BasicComboBoxUI extends Com Line 1070  public class BasicComboBoxUI extends Com
1070      }      }
1071    
1072      /**      /**
1073       * This method is invoked when items were added to the JComboBox's data       * Invoked when items are added to the JComboBox's data model.
      * model.  
1074       *       *
1075       * @param e ListDataEvent describing the change.       * @param e ListDataEvent describing the change.
1076       */       */
1077      public void intervalAdded(ListDataEvent e)      public void intervalAdded(ListDataEvent e)
1078      {      {
       // must determine if the size of the combo box should change  
       int start = e.getIndex0();  
       int end = e.getIndex1();  
   
1079        ComboBoxModel model = comboBox.getModel();        ComboBoxModel model = comboBox.getModel();
1080        ListCellRenderer renderer = comboBox.getRenderer();        ListCellRenderer renderer = comboBox.getRenderer();
1081    
1082        if (largestItemSize == null)        if (displaySize == null)
1083          largestItemSize = new Dimension(0, 0);          displaySize = getDisplaySize();
1084          if (displaySize.width < getDefaultSize().width)
1085            displaySize.width = getDefaultSize().width;
1086          if (displaySize.height < getDefaultSize().height)
1087            displaySize.height = getDefaultSize().height;
1088    
1089        for (int i = start; i < end; i++)        comboBox.repaint();
         {  
           Object item = model.getElementAt(i);  
           Component comp = renderer.getListCellRendererComponent(new JList(),  
                                                                  item, -1,  
                                                                  false, false);  
           if (comp.getPreferredSize().getWidth() > largestItemSize.getWidth())  
             largestItemSize = comp.getPreferredSize();  
         }  
1090      }      }
1091    
1092      /**      /**
1093       * This method is invoked when items were removed from the JComboBox's       * Invoked when items are removed from the JComboBox's
1094       * data model.       * data model.
1095       *       *
1096       * @param e ListDataEvent describing the change.       * @param e ListDataEvent describing the change.
# Line 1131  public class BasicComboBoxUI extends Com Line 1098  public class BasicComboBoxUI extends Com
1098      public void intervalRemoved(ListDataEvent e)      public void intervalRemoved(ListDataEvent e)
1099      {      {
1100        // recalculate display size of the JComboBox.        // recalculate display size of the JComboBox.
1101        largestItemSize = getLargestItemSize();        displaySize = getDisplaySize();
1102        comboBox.repaint();        comboBox.repaint();
1103      }      }
1104    }    }
1105    
1106    /**    /**
1107     * This class handles PropertyChangeEvents fired by JComboBox.     * Handles {@link PropertyChangeEvent}s fired by the {@link JComboBox}.
1108     */     */
1109    public class PropertyChangeHandler extends Object    public class PropertyChangeHandler extends Object
1110      implements PropertyChangeListener      implements PropertyChangeListener
1111    {    {
1112        /**
1113         * Creates a new instance.
1114         */
1115      public PropertyChangeHandler()      public PropertyChangeHandler()
1116      {      {
1117      }      }
1118    
1119      /**      /**
1120       * This method is invoked whenever bound property of JComboBox changes.       * Invoked whenever bound property of JComboBox changes.
1121         *
1122         * @param e  the event.
1123       */       */
1124      public void propertyChange(PropertyChangeEvent e)      public void propertyChange(PropertyChangeEvent e)
1125      {      {
# Line 1185  public class BasicComboBoxUI extends Com Line 1157  public class BasicComboBoxUI extends Com
1157            if ((ComboBoxModel) e.getNewValue() != null)            if ((ComboBoxModel) e.getNewValue() != null)
1158              comboBox.getModel().addListDataListener(listDataListener);              comboBox.getModel().addListDataListener(listDataListener);
1159          }          }
1160          else if (e.getPropertyName().equals("font"))
1161            {
1162              Font font = (Font) e.getNewValue();
1163              editor.setFont(font);
1164              listBox.setFont(font);
1165              arrowButton.setFont(font);
1166              comboBox.revalidate();
1167              comboBox.repaint();
1168            }
1169    
1170        // FIXME: Need to handle changes in other bound properties.              // FIXME: Need to handle changes in other bound properties.      
1171      }      }
1172    }    }
1173    
1174    /**    /**
1175     * MouseHandler listens to mouse events occuring in the combo box. This     * A handler for mouse events occurring in the combo box.  An instance of
1176     * class is responsible for repainting this JComboBox whenever the mouse is     * this class is returned by the <code>createMouseListener()</code> method.
    * being pressed or released over it.  
1177     */     */
1178    private class MouseHandler extends MouseAdapter    private class MouseHandler extends MouseAdapter
1179    {    {
1180      /**      /**
1181       * This method is invoked when mouse is pressed over the combo box. It       * Invoked when mouse is pressed over the combo box. It toggles the
1182       * repaints the combo box accordinglly       * visibility of the popup list.
1183       *       *
1184       * @param e the MouseEvent       * @param e  the event
1185       */       */
1186      public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
1187      {      {
1188        if (comboBox.isEnabled())        if (comboBox.isEnabled())
1189          {          toggleOpenClose();
           if (e.getSource() instanceof JComboBox)  
             {  
               arrowButton.getModel().setPressed(true);  
               arrowButton.getModel().setArmed(true);  
             }  
   
           comboBox.repaint();  
   
           if (e.getSource() instanceof BasicArrowButton)  
             toggleOpenClose();  
         }  
     }  
   
     /**  
      * This method is invoked when mouse is released over the combo box. It  
      * repaints the combo box accordinglly  
      *  
      * @param e the MouseEvent  
      */  
     public void mouseReleased(MouseEvent e)  
     {  
       if (comboBox.isEnabled())  
         {  
           if (e.getSource() instanceof JComboBox)  
             {  
               arrowButton.getModel().setPressed(false);  
               arrowButton.getModel().setArmed(false);  
             }  
   
           comboBox.repaint();  
         }  
1190      }      }
1191    }    }
1192  }  }

Legend:
Removed from v.1.5.2.7  
changed lines
  Added in v.1.5.2.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26