title: BoxLayout adding left margin
body: <p>I've got a JPanel that has a <code>BoxLayout</code> (Page axis), and I want to lay out two components, one on top of the other. </p>
  
  <p><a href="https://i.stack.imgur.com/AGaDn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AGaDn.png" alt="enter image description here"></a></p>
  
  <p>My problem is the margin to the left of the large lipsum box, how can I get rid of this? If I don't add the top components, there is no margin.</p>
  
  <p><a href="https://i.stack.imgur.com/ZplgQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZplgQ.png" alt="enter image description here"></a></p>
  
  <p>Here's my code, the second image is created by not adding <code>headerPanel</code>:</p>
  
  <pre><code>JLabel commandLabel = new JLabel(command);
      JLabel paramLabel = new JLabel(params);
      JLabel descLabel = new JLabel("&lt;html&gt;&lt;body style='width: 200px;'&gt;" + description + "&lt;/body&gt;&lt;/html&gt;");
      Font baseFont = commandLabel.getFont(), commandFont, paramFont, descFont;
  
      commandFont = baseFont.deriveFont(Font.BOLD);
      paramFont = baseFont.deriveFont(Font.ITALIC);
      descFont = baseFont.deriveFont(Font.PLAIN);
  
      commandLabel.setFont(commandFont);
      paramLabel.setFont(paramFont);
      descLabel.setFont(descFont);
      descLabel.setAlignmentX(LEFT_ALIGNMENT);
      descLabel.setBorder(BorderFactory.createStrokeBorder(new BasicStroke()));   
      JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
          headerPanel.add(commandLabel);
          headerPanel.add(paramLabel);
      this.add(headerPanel);
      this.add(descLabel);
  </code></pre>
  
  <p>This class extends <code>JPanel</code>, and is added to a <code>JFrame</code>, which is simply <code>pack()</code>'d</p>