Actually, I tried the following code with JBuilder4:
public class Enter extends Frame {
public Enter(){
setLayout(new FlowLayout());
this.add(new Button("1"));
this.add(new Button("2"));
this.add(new Button("3"));
this.add(new Button("4"));
this.pack();
//whether comment it out or not
//make no differerce to the result
//setVisible(true);
}
public void method()
{
setLayout(new BorderLayout());
pack();
setVisible(true);
}
public static void main(
String args )
{
Enter e=new Enter();
e.method();
}
}
what I have seen is
1) a frame with 4 buttons layouting as FlowLayout
2) after call method(), I only see the title bar of the Frame. After enlarge the frame, I see that 4 buttons layouting as FlowLayout.
?? the code shows no effect from the BorderLayout manager. Even if the BorderLayout is taking in charge, how does it figure out the constraints, i.e, NORTH, CENTER
Thank all your answers (also they are different :-)).
Originally posted by Anshuman Acharya:
[B]quan,
when you reset the layout the components are also reset according to the specifications of the new layout.
[B]