title: java BoxLayout panel's alignment
body: <p>I have browsed around and haven't found a solution that specifically tailors to my situation. I have a panel that I display in a dialog box:</p>
  
  <pre><code>//create dialog panel
  JPanel panel = new JPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  panel.add(headerPanel);
  panel.add(type1Panel);
  panel.add(type2Panel);
  panel.add(type3Panel);
  panel.add(type4Panel);
  panel.add(type5Panel);
  panel.add(type6Panel);
  
  int result = JOptionPane.showConfirmDialog(null, panel, "Please enter values.", JOptionPane.OK_CANCEL_OPTION);
  </code></pre>
  
  <p>The size of the last two panels, type5 &amp; type6, are of equal size so they look fine. However, the header and first 4 panels are of different sizes and I would like them all to be left aligned. As of yet I haven't found a good solution as how to fix this.</p>
  
  <p>Question is, how can I left align the first 5 panels, but not last 2? If not how can I left align them all? The setalignmentx() isn't available for panels. I've tried using GridLayout, but then the width of the gui's main window is rather large and doesn't fit nicely onto the screen, hence the BoxLayout along Y axis.Thanks for any help or suggestions. </p>