Hide JComboBox's ComboPopup

Hello there!

I am trying to add some functions to the JComboBox but it would be great to keep the current look and feel... So after trying to get a custom UI that would let me to build my own JComboBox, I decided to override the ComboPopup class, I couldn't find a way to do it... So I would like some pointers here.

Is there a way to block the current popup and show my own? Is there a way to build a custom combobox that would look just like the JComboBox without having to make a sub-class for each look and feel that exists?

Please help me... I found a way to block the popup but it is by raising an exception at firePopupMenuWillBecomeVisible... But that is not the purpose... I would appreciate your suggestions.

Thank you very much!

[771 byte] By [Tec-Nicoa] at [2007-10-2 7:59:17]
# 1
maybe you can play around with the code here (reply #8) http://forum.java.sun.com/thread.jspa?forumID=57&threadID=652465
Michael_Dunna at 2007-7-16 21:50:34 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thank you, I am going to play around with the code and let you know. :)
Tec-Nicoa at 2007-7-16 21:50:34 > top of Java-index,Desktop,Core GUI APIs...
# 3

Michael, I played with that code but it shows a very small square (the popup menu) and on top of that, it displays the combobox under a basic UI look... so if anyone changed the look and feel would it still work and look as the usual JComboBox?

I found a way to get the ComboPopup to be prevented for being shown... Actually two ways:

- The first one is to provoke the exception like I stated in my first post. I am wondering if by settling the default exception catcher the exception wouldn't be shown (I need JDK 1.5 for this, though)

- The second one is to get the current thread running and stopping it (in the same method). However, this way relays on a deprecated method... (Remember the ComboPopup is shown in a different thread so that it gives the sensation of being shown at the same time they are clicking on the arrow button)

So... Would anyone have a different method or idea to help me out?

Thank you very much! :)

Tec-Nicoa at 2007-7-16 21:50:34 > top of Java-index,Desktop,Core GUI APIs...
# 4

> it shows a very small square (the popup menu)

adding this line gets rid the small square

popup.setPreferredSize(new Dimension(0,0));

> so if anyone changed the look and feel would it still work and look as the usual JComboBox?

all worked the same (no popup) under Windows, Metal and Motif L&F's

Michael_Dunna at 2007-7-16 21:50:34 > top of Java-index,Desktop,Core GUI APIs...