Oops. I should have waited to read John Z's reply. I was suggesting a
slightly different implementation of the same thing.

-----Original Message-----
From: Farwell, Paul [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 21, 2001 8:14 AM
To: 'Jeroen Zwartepoorte'; Jeff Leuschner; Advanced Swing Mailing list
Subject: RE: Dynamic Combo Box


If you don't want to wait until 1.4, you can get around the problem by
creating your own ComboBoxUI and exposing the popup listener. (You could
also expose the action listener for the arrow button). 

  class MyComboBoxUI extends MetalComboBoxUI {

      private JPopupMenu _popup;

      protected ComboPopup createPopup() {
         // we are cheating a little. There is a very
         // unlikely possiblity that MetalComboPopup
         // will no longer extend JPopupMenu.
         ComboPopup popup = super.createPopup();
         _popup = (JPopupMenu)popup;
         return popup;
      }

      public void addPopupMenuListener(PopupMenuListener l) {
         if (_popup != null)
            _popup.addPopupMenuListener(l);
      }
   }

Then add a popup listener to your particular combobox instance:

   public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {
      hidePopup();
      // do your expensive operation here
      showPopup();
   }

Not elegant, but it works.

-----Original Message-----
From: Jeroen Zwartepoorte [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 20, 2001 4:49 PM
To: Jeff Leuschner; Advanced Swing Mailing list
Subject: RE: Dynamic Combo Box


Hi,

I think this is a new feature of jdk 1.4. I seem to remember reading about
this some on the java.sun.com/jdc site.

Jeroen

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Jeff Leuschner
> Sent: Tuesday, February 20, 2001 10:25 PM
> To: Advanced Swing Mailing list
> Subject: Dynamic Combo Box
>
>
> I want to tweak somehow the JComboBox so that I listen for the
> arrow press and when the arrow is pressed on the combo box, go
> out and populate the list of items vs populating the list up
> front. The reason for this is that populating this up front
> may be expensive since the combo is loaded from a file and we
> have multiple combo's.
>
> Any suggestions?
>
> Thanks
>
> Jeff
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing
>
>

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to