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 Problem with resizing 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 "Problem with resizing JComboBox" Watch "Problem with resizing JComboBox" New topic
Author

Problem with resizing JComboBox

Mark Heydenrych
Greenhorn

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
container.add(comboBox);

try it like this
JPanel panel = new JPanel();//use default FlowLayout
panel.add(comboBox);
container.add(panel);

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

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: http://aspose.com/file-tools
 
subject: Problem with resizing JComboBox
 
Similar Threads
add listener to combo drop down list
CSS & DIV relative alignment
HTML page�s height and width
RichComboBox inside a scrollable div.
refresh the contents of combobox