// This code example is created for educational purpose // by Thorsten Thormaehlen (contact: www.thormae.de). // It is distributed without any warranty. import javax.swing.*; import java.awt.Container; import java.awt.BorderLayout; class MyGui extends JFrame{ public void createGUI() { setTitle("HelloGUI"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(320, 240); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout(0,0)); contentPane.add(BorderLayout.NORTH, new JButton("North")); contentPane.add(BorderLayout.EAST, new JButton("East")); contentPane.add(BorderLayout.SOUTH, new JButton("South")); contentPane.add(BorderLayout.WEST, new JButton("West")); contentPane.add(BorderLayout.CENTER, new JButton("Center")); setVisible(true); } } public class MyBorderLayout { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { MyGui myGUI = new MyGui(); myGUI.createGUI(); } }); } }