This is a question from Jexam..
Select the statement which most closely describes the user interface of an
applet with the following init() method:
public void init(){
Panel p = new Panel();
p.setLayout(new BorderLayout());
p.add(new Button("Hello"), BorderLayout.EAST);
p.add(new Button("Bye"), BorderLayout.WEST);
add(p);
}
##ans1##
Two buttons are displayed. A button with "Hello" is on the right side of the applet. The button with "Bye" is on the left side of the applet. Both buttons extend from the centre of the applet to each side, and are the height of the applet.
##ans2##
Two buttons are displayed. A button with "Hello" is on the right side of the applet. The button with "Bye" is on the left side of the applet. Both buttons are only as wide as the text on the button, but are the height of the applet.
##ans3##
Two buttons are displayed. A button with "Hello" is on the right side of the applet. The button with "Bye" is on the left side of the applet. Both buttons are only large enough to support the associated button texts.
The answer is given as 2.
But i think the answer should be 2. sinec the default layout of an applet is FlowLayout, and in FlowLayout , the components are given their preferred width and preferred height, when u add an panel to it it occupies only the north region of the applet. it will occupy the entire applet. so, when u add buttons to this panel, they would be only large enough to accomodate their button text's.
Please correct me if i am wrong
Thank U.
Mary.