Border layout in java
BorderLayout:
The BorderLayout class divides
the entire applet screen into five sections , North,South,East,West and Center.
Constructors of the BorderLayout
class
(a)
Border Layout()
This
is the defalut constructor of the BorderLayout class.
(b)
Border Layout(int hgap,int vgap)
This
constructor is used to define the horizontal and the vertical gap which is to be
left between the components.
import java.awt.*;
/*
<applet
code="BorderLayout1" height=200 width=200>
</applet>
*/
public class BorderLayout1
extends Applet
{
public
void init()
{
setLayout(new
BorderLayout(5,5));
Button
b1=new Button("Button1");
Button
b2=new Button("Button2");
Button
b3=new Button("Button3");
Button
b4=new Button("Button4");
Button
b5=new Button("Button5");
add(b1,"North");
add(b2,"South");
add(b3,"East");
add(b4,"West");
add(b5,"Center");
}
Comments
Post a Comment