Java AWT BorderLayout fill all area
import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; public class Main { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("BorderLayout frame"); //w w w . j av a 2 s . c om /* Since the default layout manager for bordered containers is * already a BorderLayout, the following line is OPTIONAL here. */ frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(new JButton("NORTH"), BorderLayout.NORTH); // ... or BorderLayout.PAGE_START frame.getContentPane().add(new JButton("WEST"), BorderLayout.WEST); // ... or BorderLayout.LINE_START frame.getContentPane().add(new JButton("EAST"), BorderLayout.EAST); // ... or BorderLayout.LINE_END frame.getContentPane().add(new JButton("SOUTH"), BorderLayout.SOUTH); // ... or BorderLayout.PAGE_END frame.getContentPane().add(new JButton("CENTER"), BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } }