BorderLayout
Completion requirements
BorderLayout
Here is a small demonstration showing how the BorderLayout places components added with the region constraints.
import javax.swing.*;
public class BorDemo extends JFrame{
JButton n = new JButton("North");
JButton e = new JButton("East");
JButton s = new JButton("South");
JButton w = new JButton("West");
JButton c = new JButton("Centre");
public static void main(String argv[]){
BorDemo b = new BorDemo();
}
BorDemo(){
getContentPane().add(n,"North");
getContentPane().add(e,"East");
getContentPane().add(s,"South");
getContentPane().add(w,"West");
getContentPane().add(c,"Center");
setVisible(true);
setSize(300,300);
}
}
Note how the add method is overloaded to take a region constraint.
This is how the program displays itself.
Last modified: Thursday, 24 July 2014, 2:54 PM