1.Border Layout never honours preferred size of component. //TRUE 2.Border Layout always honours preferred height of component. //FALSE This is what is given is Ashok JavaApplet. I think it should be other way round ie. FALSE for 1 and TRUE for 2, as BorderLayout honours preferred height in N-S and width is E-W. Someone pls clarify. Deepali
You wrote "as BorderLayout honours preferred height in N-S and width is E-W." I agree w/you w/that... "The East and West regions are the opposite of North and South: In E and W, a component gets to be its preffered width but has its height constrained." This is from Complete Java 2 Certification Study Guide by M. Ernest
What out ! What does "preferred size" mean ? It means " Under any circumstances, the component's size specified by the programmer will never change ". Only FlowLayout honours a component's size even when the hosting container's size changes. The heights of the south and north components are fixed. That is true but don't mistake it with "the programmer can specify the size and the size will never change". You cannot PREFER to have a certain height for the south and north components. You have no choice but to let the BorderLayout choose the height for the south and north components.
Originally posted by Deepali Pate: [QB]1.Border Layout never honours preferred size of component. //TRUE 2.Border Layout always honours preferred height of component. //FALSE Deepali, in my opinion , both the answers are correct. The important words here are 'never ' and 'always '. In 1 , the statement is true as , the components are placed in the frame as per their location irrespective of all their dimensions.The layout 'never ' honours the size of the components,for example if you have placed components in the North ans South , they take up the whole of the North and South, irrespective of their preferred width ,and the same goes for the components placed in the east and west , they take up the height available , not their preferred height .WHich also explains the second answer ... In 2 , the statement is false as , the preferred height of the components is not 'always ' honoured. I hope this is clear..
Nupur. <br />SCJP2.
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad: