• 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

GridBag Layout

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic