aspose file tools
The moose likes Swing / AWT / SWT / JFace and the fly likes GridBag Layout Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "GridBag Layout" Watch "GridBag Layout" New topic
Author

GridBag Layout

selvas kumars
Ranch Hand

Joined: Jan 06, 2001
Posts: 115
I am having 3 components JList,SelectionButton ,Jlist in horizontal order.Both JList are of equal size and selectionButton is centered and width is small..Looks fine even when resized..
The problem comes when i add items to the first Jlist.This becomes smaller and the last JList increases it's width ..
After selection of items from left to right still the size remains constant.How to solve this problem.At any point,both Jlist should be of equal width..I don't want to use setPreferredSize().

Constarints for the JList used
1)Constarints for first JList
GridBagConstraints gbb = new GridBagConstraints();
gbb.gridx=0;
gbb.gridy=0;
gbb.gridwidth=4;
gbb.weightx=1.0;
gbb.weighty=1.0;
gbb.fill = GridBagConstraints.BOTH;
2)Constraints for second JList
gbb.gridx=6;
gbb.gridy=0;
gbb.gridwidth=4;
gbb.weightx=1.0;
gbb.weighty=1.0;
gbb.fill = GridBagConstraints.BOTH;
Thanks
Regards,
silva.
anandh
Greenhorn

Joined: Sep 06, 2001
Posts: 22
Change the gridBagConstraints.fill to NONE. This will prevent the component from resizing from its original shape. Also, it's good to set weightx and weighty to 100 first.
 
 
subject: GridBag Layout
 
Threads others viewed
horizontal weight of a component
GridBagLayout. and GridBagConstraints..Help me!!
Scroll pane problem
GridBagLayout resize issue
Problem with gridbaglayout
developer file tools