title: Java calendar grid layout
body: <p>I'm trying to get the month of April calendar to get the day count started. So far all I have is a pretty generic calendar that starts with one at the beggining of the grid. How do I set it up so that the calendar matches the first day of the April (Tuesday). Here is my code so far:</p>
  
  <pre><code>package Exercise15_5;
  import java.awt.*;
  import javax.swing.*;
  import java.util.*;
  
  public class Exercise15_5 extends JFrame {
      public Exercise15_5(){
          //Create panel with gridlayout
          JPanel calendar = new JPanel(new BorderLayout());
          calendar.setLayout(new GridLayout(6,7));
          //Add headers
          String[] headers = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
          for(int i = 0; i &lt;7; i++){
              calendar.add(new JLabel("" + headers[i]));
          }
          // Add days to calendar, use String.valueOf
          Calendar calendar1 = new GregorianCalendar(2014,4, 13);
          for (int i = 1; i &lt; 31; i++) {
            calendar.add(new JLabel(String.valueOf(i)));
          }
  
          JPanel monthHeader = new JPanel(new BorderLayout());
          monthHeader.add(new JTextField("\t\t\t04/2014"),    BorderLayout.NORTH);
  
          monthHeader.add(calendar, BorderLayout.CENTER);
  
  
  
          add(monthHeader);
      }
  
      public static void main(String[] args) {
          Exercise15_5 frame = new Exercise15_5();
          frame.setTitle("Exercise 15_5");
          frame.setSize(600,300);
          frame.setLocationRelativeTo(null);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
  
  
      }
  
  }
  </code></pre>