title: How can I center and widen out my JPanel in my JFrame?
body: <p>I am making a copy of the apple calendar application, and I am having trouble aligning the month name and year name with the center of my screen, while aligning the left and right buttons with the left and right sides of the screen. Here is my code:</p>
  
  <pre><code>final JPanel months = new JPanel();
  months.setLayout(new BoxLayout(months,BoxLayout.X_AXIS));
  months.add(back, BorderLayout.WEST); //back is a JButton
  JLabel monthName = new JLabel(this.monthNames[this.month]+" ", SwingConstants.CENTER); 
  JLabel year = new JLabel("" + this.year, SwingConstants.CENTER);
  monthName.setFont(new Font("Helvetica", 0, 24));
  year.setFont(new Font("Helvetica", 0, 24));
  monthName.setHorizontalAlignment(JLabel.CENTER);
  months.add(monthName, BorderLayout.CENTER);
  months.add(year, BorderLayout.CENTER);
  months.add(front, BorderLayout.EAST);
  add(months);
  </code></pre>
  
  <p>Yet it shows up like this:  </p>
  
  <p><img src="https://i.stack.imgur.com/RasfN.png" alt="http://i.stack.imgur.com/RasfN.png"></p>