• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

weightx and weighty

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
Should weightx and weighty have value between 0.0 and 1.0
I think yes!!!
Mark
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reading the API and I think you �re wrong. I understand that the value must be 0 or higher.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following was taken, verbatim, from the JBuilder3.5 help...
Weight
Use the Weight constraints to specify how to distribute the extra container space vertically (weightx) and horizontally (weighty) when the container is resized. Weights determine what
share of extra space each component gets when the container is enlarged beyond its default size.
For example, if you have three components with weights of 0.0, 0.3, and 0.2 respectively, when the container is enlarged, none of the extra space will go to the first component, 3/5 of it will
go the second component, and 2/5 of it will go to the third.
Note: If all the components have weights of zero in a single direction, the components will clump together in the center of the container for that dimension and won't expand beyond their
preferred size. GridBagLayout puts any extra space between its grid of cells and the edges of the container.
Weight values are of type double and are specified numerically in the range 0.0 to 1.0 inclusive. Zero means the component should not receive any of the extra space, and 1.0 means
component gets a full share of the space.
 
AJ Dussault
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://nimbus.temple.edu/~jmillawa/GridBag/GridBag.html
this is a pretty neat spot for playing with the different constraints for GridBagLayout....
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much both of you .
Mark
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see any reason why the weights cannot be greater than 1.0.
Suppose a row has 3 buttons which have weightx values 3.0, 4.0 and 5.0 respectively, then GridBagLayout calculates the relative weights by proportion, i.e. 3.0/12.0, 4.0/12.0 & 5.0/12.0 resp.

 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic