aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes  How to fix ListBox and Panel size .. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark " How to fix ListBox and Panel size .." Watch " How to fix ListBox and Panel size .." New topic
Author

How to fix ListBox and Panel size ..

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
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

Joined: Nov 26, 2000
Posts: 133
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


<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to fix ListBox and Panel size ..
 
Similar Threads
Layout issue
how to retain selected value.....
Java Servlet and Dynamic List box
GridBagLayout Problem
Problem with GridLayout.