• 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
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

GridBagLayout

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the following statement true or false?
If you specify the anchor field in the GridBagLayout, there is
no meaning to set fill field to BOTH.
By the way, in GridBagLayout, what is the difference between
anchor field, fill field and pad field?
Thanks!
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I give you a good link for this. Please read this and play with the sample code given. You WILL definitely be able to answer your qstn. Because this is the ONLY BEST WAY you can takle GBLayout qstns. Just giving answer WILL NOT help atleast for this case.
Please come back after testing info in this link. We will definitly be here for you.
regds
maha anna
Good tutorial for GridBagLayout is here
 
Wai Iu
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, anna, I read the tutorial that you recommended. It's helpful.
So, according to my understanding, the following statament
should be correct.
"If you specify the anchor field in the GridBagLayout, there is
no meaning to set fill field to BOTH."
Am I right?

 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wai Iu,
It is the other way around. When you set the fill field of GBC to BOTH, then the anchor field has no effect
The idea here is both fields anchor and fill comes into picture when a component in a row/col gets extra space than the the size of the component itself. So when a comp gets lots od space, where to anchor the component? In Java AWT if you take any component, it is of shape Rectangle. Isn't? So GBC has totally 8 compass directions to anchor the comp. Go from NORTH to clockwise. NORTH/NORTHEAST/EAST/SOUTHEAST/SOUTH/SOUTHWEST/WEST/NORTHWEST. So the tiny comp. can be set to one of the above 8 directions. The anchor field has done its part.
The fill field is used to In which direction (Horizantal/vertical/None/Both) to stretch. When you set this field to BOTH, the LayoutManager stretches the comp to ALL available space right? Then where is the qstn of where to anchor the comp? It is spread all over its allocated space already.
Also note that GridBagLayout gives the combined effect of all its fields (fill/anchor/ipadx/ipady/gridx/gridy/gridwidth/gridheight/weightx/weighty/insets...Are they enough )when placing a comp.
regds
maha anna
[This message has been edited by maha anna (edited April 09, 2000).]
 
You can't have everything. Where would you put it?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic