Saturday, 18 May 2019

Border Layout in Java - Online Help

Border Layout in java:

The border layout class allows geographic terms: North, South, East, West, Center. The border Layout class has two constructors.namely,

BorderLayout()
It is used to create a default border layout.

BorderLayout(int h,int v)

It is used to create a border layout with the specified horizontal and vertical space between components. The border layout defined the following regions.
BorderLayout.NORTH
BorderLayout.SOUTH
BorderLayout.EAST
BorderLayout.WEST
BorderLayout.CENTER

Sample program:

import java.awt.*;
import java.Applet.*;
public class BorderLayoutDemo extends Applet
{
public void init()
{
setLayout(new BorderLayout(5,5));
Button b1=new Button("North");
Button b2=new Button("south");
Button b3=new Button("east");
Button b4=new Button("west");
Button b5=new Button("center");
add(b1,"North");
add(b2,"south");
add(b3,"east");
add(b4,"west");
add(b5,"center");
}
}

No comments:

Post a Comment