This is a question from Abhilash's site with some experimenting of my own.Consider the follwing code:-
import java.awt.*;
public class TestFrame extends Frame
{
Button bNorth = new Button("North");
Button bSouth = new Button("South");
Button bEast = new Button("East");
Button bWest = new Button("West");
Button bCenter = new Button("Center");
public TestFrame()
{
setLayout(new FlowLayout());
add(bCenter);
add(BorderLayout.SOUTH,bSouth);
add(bWest,BorderLayout.WEST);
add(bEast,BorderLayout.EAST);
add(bNorth,BorderLayout.NORTH);
setLayout(new BorderLayout());
//setLayout(null);
//validate();
//pack();
setSize(400,400);
setVisible(true);
}
public static void main(
String args[])
{
TestFrame tf = new TestFrame();
tf.setLayout(new FlowLayout()); //after resizing the frame takes flowlayout
}
}
If u run this code there is only a frame constructed,no buttons are visible.How come,coz I think that the center button should be visible since it is using the add() which is valid for FlowLayout.I agree that the other buttons shouldn't be seen.
If you interchange the setLayout() viz,first BorderLayout then FlowLayout then the Frame is set to FlowLayout,why may I ask??
Help me somebody,
Desperately seeking help,
Vedhas.