Question 4. To increase size of a button in a Frame with GridBag Layout manager as its Layout manager, which of the following best describes what you do.
A.We can't do any thing like this irrespective of the layout policy of the container. B.Use setFill method of GridBagLayout class. C.Use setFill method of GridBagConstraints class D.Use fill() method of GridBagLayout class.
The correct answer given is D but i think it is wrong! pls explain thanx a lot in advance
Hi Mate, The fill feature controls how a component is streched when it's default size is smaller than the cell it has been given to occupy. The values for fill are constants defined in the GridBagConstraints class. So to my mind ( not certified yet ) that would mean D is correct. I'm not to sure what setFill does though. Best of Luck in the exam!!
The constants mentioned above are used to set the int fill argument of the constructor. I also feel that a components size can be altered by playing around with the ipadx and the ipady fields. A component's size is always guaranteed to be Component Size + 2*ipadx + 2*ipady. The "2" here is for both sides of a component (Top, bottom in the case of ipady and Left, Right in the case of ipadx). If these values are > 0 then the components' size gets adjusted. Visit this site for a great tutorial on the GridBagLayout. Hope this helps Shyam
[This message has been edited by Shyamsundar Gururaj (edited November 07, 2001).]