Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

GridBagLayout

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
I was giving JavaCaps mock exam wherein I came across this question. I marked the answer as 3 and 4 but the answer according to the exam is 1,2,3 . Can you just tell me if I am correct or the answer given in the exam is correct.
1. Which statements are true about GridbagLayout?
1. Weightx and weighty should be 0 and 1.0
2. If fill is both anchor does not make sense
3. It divides its territory into array of cells
4. While constructing GridBagLayout, you wont tell how many rows and columns the underlying grid has.
Thank you
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Which statements are true about GridbagLayout?
1. Weightx and weighty should be 0 and 1.0
- NO. you can have values greater than 1.0 & less than 0 for weightx and weighty. the code would compile just fine. But what matters is not the actual value you assign, but the relative values of weightx and weighty.
2. If fill is both, anchor does not make sense.
- YES. 'anchor' is used to specify where to place a component when it is smaller than its display area. But when fill is BOTH, the component occupies its entire display area. So it is meaningless to specify 'anchor'.
3. It divides its territory into array of cells
- YES.for obvious reasons.

4. While constructing GridBagLayout, you won't tell how many rows and columns the underlying grid has.
-NO. At first, this might seem right. The GridBagLayout is a dynamically growing array of cells.There is no constructor to specify the rows & columns explicitly. But using gridx and gridy we can specify the row & column every component should go to. That way we are specifying how many rows & columns the grid finally has.
So I think the correct answers are: 2 and 3.
Regards,
Kamakshi.
[This message has been edited by Kamakshi Mahadevan (edited November 11, 2000).]
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kamakshi,
I guess the answer you gave is also incorrect:
1. Which statements are true about GridbagLayout?
1. Weightx and weighty should be 0 and 1.0
WRONG. Weightx and weighty can be any valid double value
2. If fill is both anchor does not make sense
CORRECT
3. It divides its territory into array of cells
CORRECT
4. While constructing GridBagLayout, you wont tell how many rows and columns the underlying grid has.
CORRECT. The question asked is "While constructing GridBagLayout", which means, in the constructor, you don't specify the number of rows and columns. Hence 4th option is CORRECT.
Any other opinions?
Thanks,
Aparna
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic