// Create a panel and set its layout JPanel panel = new JPanel(); panel.setLayout(new BorderLayout());