This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Not Possible in Java ? : drop-up JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Not Possible in Java ? : drop-up JComboBox" Watch "Not Possible in Java ? : drop-up JComboBox" New topic
Author

Not Possible in Java ? : drop-up JComboBox

raphael Bereh
Ranch Hand

Joined: Jan 15, 2002
Posts: 79
Went through old post and saw the question raised more than once, and no solution !
Well I need my Combo Box list to drop Up instead of down !
Any Swing guru to help ?


SCJP,SCJD,SCBCD
Eric Snell
Greenhorn

Joined: Jun 09, 2004
Posts: 28

Originally posted by raphael Bereh:
Well I need my Combo Box list to drop Up instead of down !


Here's a subclass of MetalComboBoxUI that pops up above the combo:



Install the UI in your combo with:


Now the problems:
1. If the popup will be off the screen, it is moved down. A better solution would be to allow it to drop down instead. See the implementation of BasicComboPopup.computePopupBounds for example code to do this.
2. This solution requires you to subclass a specific ComboBoxUI. I think it would have been better to delegate so as to make the solution applicable to any UI. The only way I see of getting acces to the popup in BasicComboBoxUI is subclassing or reflection. So I can't get the current popup to delegate to it.

Anyway, this solution is relatively simple and you can customize it as necessary.
raphael Bereh
Ranch Hand

Joined: Jan 15, 2002
Posts: 79
Looks greate,
Thanks Eric,
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Yeah, it's really kool... And it's worthful to know such thing for me...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Possible in Java ? : drop-up JComboBox
 
Similar Threads
Game on SQL
WA #1.....word association
Changing the default WebApp
option list & or Functions
NIC Card Problem