• 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

How to fix ListBox and Panel size ..

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to fix ListBox and Panel size in an applet using GridBagLayout as Layout manager?
I have an applet with a Panel and two ListBoxes in the Panel. The layout manager I use is GridBagLayout.
When I populate the listboxes with data (string). Their size (both the panel and listbox) vary with the length of data string. How can I fix the size of these listboxes and panel? How can utilize the preferredSize() and getPreferredSize() methods? Will they help? Thanks in advance.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gridbag layout references getPreferredSize, and getMinimumSize (info courtesy of Professional Java Programming, WROX press, thanks Java Ranch!) so you will need to set both of them to the size you want. Ie:
combo.setPreferredSize(100,20);
combo.setMinimumSize(100, 20);
HTH
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic