title: Java Swing Glue not working between 2 buttons
body: <p>I am trying to make my own little game in Java as a personal excercise however I am finding a lot of issues using BoxLayout's in Java Swing.</p>
  <p>So I have a basic MVC application and I need two buttons at the top both &quot;New Game&quot; and &quot;Submit&quot; to both be on the same line in the GUI. I have found out that I can use glue to do this however all of the guides I have found on it, do not work. Am I missing something obvious here?</p>
  <p><img src="https://i.stack.imgur.com/uWtIx.png" alt="" />This is my view code (my GUI):</p>
  <pre><code>package mvc;
  
  import java.awt.*;
  import java.awt.event.ActionListener;
  import java.util.Map;
  import java.util.Set;
  import javax.swing.*;
  
  public class View extends JFrame {
      //User input Characters
      private JTextField firstChar = new JTextField(1);
      private JTextField secondChar = new JTextField(1);
      private JTextField thirdChar = new JTextField(1);
      private JTextField fourthChar = new JTextField(1);
      private JTextField fifthChar = new JTextField(1);
      
      //Displays on GUI
      private JButton submitButton = new JButton(&quot;Submit&quot;);
      private JButton newButton = new JButton(&quot;New Game&quot;);
  
      View() {
          JPanel gamePanel = new JPanel();
          gamePanel.setLayout(new BoxLayout(gamePanel, BoxLayout.Y_AXIS));
          
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setSize(600, 200);
          
          gamePanel.add(submitButton);
          gamePanel.add(Box.createHorizontalGlue());
          gamePanel.add(newButton);
          
          gamePanel.add(firstChar);  
          
          gamePanel.add(secondChar);
          gamePanel.add(thirdChar);
          gamePanel.add(fourthChar);
          gamePanel.add(fifthChar);
          
          this.add(gamePanel);
      }
  }
  </code></pre>
  <p>Any help would be massively appreciated!</p>
  <p>I have tried using glue and rigid area's to solve this however neither worked. I am expecting both buttons to be on the same line in my GUI</p>