• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with resizing JComboBox

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thank you!

You are a champion. Thanks so much dude. Worked perfectly. Looks much nicer
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic