BOREDER LAYOUT IN JAVA:
Border layout is used when we want to fill components in all available place.When the window is enlarge component occupy the all available area we can also use this layout to occupy any one or two of following area.
PAGE_START
PAGE_END
LINE_START
LINE_END
CENTER
LINE_END
CENTER
Following program illustrates how to use each of these BorderLayout constant.
CODING:
import javax.swing.*;import java.awt.*;
class myjframe1 extends JFrame
{
public myjframe1()
{
setTitle("Border Layout");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400, 600);
setLayout(new BorderLayout(20,20));
JButton button = new JButton("Button with page start layout");
add(button,BorderLayout.PAGE_START);
JButton button1 = new JButton("Button with page end layout");
add(button1,BorderLayout.PAGE_END);
JButton button2 = new JButton("Button with line start layout");
add(button2,BorderLayout.LINE_START);
JButton button3 = new JButton("Button with line end layout");
add(button3,BorderLayout.LINE_END);
JButton button4 = new JButton("Button with center layout");
add(button4,BorderLayout.CENTER);
setVisible(true);
}
}
class simpframe
{
public static void main(String args[])
{
myjframe1 x= new myjframe1();
}
}
can you please explain the code more simple.
ReplyDelete