This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to fix ListBox and Panel size ..

 
Alex Iordache
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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.
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic