title: Setting size of JButton inside JPanel with BoxLayout doesn't work as expected
body: <p>Recently, I have started doing UI development in Java; I used to do UI development in WPF. 
  Some things about Java way of doing things are confusing.</p>
  
  <p>What I am trying to achieve is to set minimum size of a button.
  Here is the simplified code:</p>
  
  <pre><code>public class MainGameView extends JPanel {  
      public MainGameView(DefaultController controller) {
  
          this.controller = controller;
          CreateUI();
      }
  
      private void CreateUI() {
          MenuPanel = new javax.swing.JPanel();
          StartGameBtn = new JButton("Start Game"); 
  
          // Creating menu
          MenuPanel.setLayout(new BoxLayout(MenuPanel, BoxLayout.Y_AXIS));
          MenuPanel.setPreferredSize(new Dimension(200, 200));
  
          StartGameBtn.setAlignmentX(Component.LEFT_ALIGNMENT);     
          StartGameBtn.setMinimumSize(new Dimension(200, 30)); 
          MenuPanel.add(StartGameBtn);
      } 
  }
  </code></pre>
  
  <p>So to my understanding, if the container gets allocated 200 pixels as its width, it should accordingly allocate 200 pixels of width to the button. However button stays the same size. Am I missing something here?</p>