souLTower
souLTower

Reputation: 696

Java ComboBox What controls where list will display?

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

Upvotes: 0

Views: 743

Answers (1)

jarnbjo
jarnbjo

Reputation: 34313

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().

Upvotes: 2

Related Questions