Here we r adding panel to the frame in the south position.and default layout for the frame is border.so,the panel containing those buttons should be placed in the bottom of the frame.
But iam not getting the authors point.can anyone tell me thhe reason.
import java.awt.*;
public class CompLay extends Frame{
public static void main(
String argv[]){
CompLay cl = new CompLay();
}
CompLay(){
Panel p = new Panel();
p.setBackground(Color.pink);
p.add(new Button("One"));
p.add(new Button("Two"));
p.add(new Button("Three"));
add("South",p);
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
}
}
1) The buttons will run from left to right along the bottom of the Frame
2) The buttons will run from left to right along the top of the frame
3) The buttons will not be displayed
4) Only button three will show occupying all of the frame
Answer 16)
Objective 8.2)
2) The buttons will run from left to right along the top of the frame
The call to the setLayout(new FlowLayout()) resets the Layout manager for the entire frame and so the buttons end up at the top rather than the bottom.