posted 22 years ago
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).]