views:

141

answers:

1

Possibly an odd question but how can I change how my Java Swing combo box displays its list of items? The default behavior is for the list to be displayed below the combo box. There are times, when the combo box is low on the screen, that the list is displayed above the combo box. Is there a way to force it to always display above? What if I wanted the list to "pop out" and float above the form displaying larger than the normal size? Are these things possible?

Thanks ST

+2  A: 

The display location and size of the popup is not decided by the JComboBox itself, but by the installed look & feel. You can either provide your own look & feel or wrap the currently installed one by overriding javax.swing.plaf.basic.BasicComboBoxUI#createPopup() to provide your own implementation of javax.swing.plaf.basic.BasicComboPopup#getPopupLocation() and javax.swing.plaf.basic.BasicComboPopup#computePopupBounds().

jarnbjo
Thank you very much.
souLTower