/** initComponents */ public void initComponents() { mainPanel = new JPanel(); emailPanel = new JPanel(); passwordPanel = new JPanel(); buttonPanel = new JPanel(); // Box layout so that all components are stacked vertically mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); emailPanel.setLayout(new BoxLayout(emailPanel, BoxLayout.X_AXIS)); passwordPanel.setLayout(new BoxLayout(passwordPanel, BoxLayout.X_AXIS)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); emailLabel = new JLabel("E-mail Address: "); emailTextArea = new JTextArea(); emailTextArea.setMaximumSize(new Dimension(300, emailTextArea.getMinimumSize().height)); emailPanel.add(emailLabel); emailPanel.add(emailTextArea); passwordLabel = new JLabel("Password:"******"Back"); loginButton = new JButton("Login"); buttonPanel.add(backButton); buttonPanel.add(loginButton); mainPanel.add(Box.createVerticalStrut(20)); mainPanel.add(emailPanel); mainPanel.add(passwordPanel); mainPanel.add(buttonPanel); // Set the panel the the contentpane of the frame getContentPane().add(mainPanel); // Close form when you click the X setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); }