question about awt

import java.awt.*; import java.applet.Applet; public class tcenter extends Applet { public void init(){ setLayout(new BorderLayout()); Panel p2=new Panel(); p2.add(new Button("n"),BorderLayout.NORTH); p2.add(new Button("s"),BorderLayout.SOUTH); Panel p =new Panel(); p.setBackground(Color.white); this.add(p,BorderLayout.CENTER);// 1 p.add(p2,BorderLayout.CENTER); } } what is this refer to in line 1 as if i replace it with tcenter it gives me error 2: why the result is like flow layout i.e. two buttons appearing in center not on north and south

Kashif, First you should be aware that both Applet and Panel have FlowLayout as the default. Your code has only changed the Applet (this) to have a BorderLayout. Therefore, your panel p2 of which you are placing your buttons onto has a FlowLayout. Also your panel P has a FlowLayout also. To get the correct result you need to create your Panel with the following command: Panel newPanel = new Panel( new BorderLayout() ); Then your example should give you what you want ... Enjoy, Manfred.