my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes Problem with resizing JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with resizing JComboBox" Watch "Problem with resizing JComboBox" New topic

Problem with resizing JComboBox

Mark Heydenrych

Joined: Mar 07, 2009
Posts: 7
Hey guys.

I really hope someone can help me, I'm having some weird bugs with JComboBoxes. I want to resize a combobox so that it looks, well, frankly, like a normal drop down list. Now I can modify the width without any problem. But try as I might, the height of the combobox fills the window from top to bottom. So I have a single itme in my box, which is exactly the way a want it, but I have miles of whitespace above and below this item, which I don't want. I've set the PrefferedSize, MaximumSize and MinimumSize, and they've constricted the width exactly as I wanted, but the height stubbornly refuses to change. If anybody could help me, you would make me a very happy bunny.

Thanks all

God loved the birds and made trees.
Man loved the birds and made cages.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
sounds like you are using the wrong layoutmanager.

currently you are adding the combobox to a container (panel/frame/whatever),
try adding the combobox to an intermediary panel and see what happens

instead of

try it like this
JPanel panel = new JPanel();//use default FlowLayout

if this doesn't work, post your code so we can see what you're doing
Mark Heydenrych

Joined: Mar 07, 2009
Posts: 7

Thank you!

You are a champion. Thanks so much dude. Worked perfectly. Looks much nicer
I agree. Here's the link:
subject: Problem with resizing JComboBox
It's not a secret anymore!