title: How to make JPanel sizes relative to JFrame size
body: <p>Im pretty new to Java (and programming). Trying to figure out how to make Jpanel sizes relative to the JFrame size.  I'm just trying to create a calendar and I have three different panels: one for the month title; one for the days of the week; and another for the calendar body.</p>
  <p>Here's my code:</p>
  <pre><code>public DisplayACalendar() {
      setLayout(new GridLayout(3, 1));
      
      // create JPanel for month/year
      JPanel monthTitle = new JPanel();
      monthTitle.add(new JLabel(month + &quot; &quot; + year));
      
      // create JPanel for Days of Week
      String[] days = {&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;,
                       &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;};
      JPanel daysOfWeekPanel = new JPanel(new GridLayout(1, 7));
      for (int i = 0; i &lt; 7; i++) {
          daysOfWeekPanel.add(new JLabel(days[i]));
      }
      
      // Create JPanel for calendar dates
      JPanel calendarMonth = new JPanel(new GridLayout(6, 7));
      for (int i = 1; i &lt; firstDay; i++) 
          calendarMonth.add(new JLabel());
      for (int i = 1; i &lt;= daysInMonth; i++) {
          JLabel jlblDayCell = new DayCell(i);
          jlblDayCell.setHorizontalAlignment(JLabel.RIGHT);
          calendarMonth.add(jlblDayCell);
      }
      int daysLeft = 42 - daysInMonth - firstDay;
      for (int i = 0; i &lt; daysLeft; i++)
          calendarMonth.add(new JLabel());
      
      add(monthTitle);
      add(daysOfWeekPanel);
      add(calendarMonth);
      
  }
  </code></pre>
  <p>And here's the Result:</p>
  <p><a href="https://i.stack.imgur.com/r15KE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r15KE.jpg" alt="JFrame Calendar" /></a><br />
  <sub>(source: <a href="https://farm8.staticflickr.com/7391/9623845560_d0c8f45cd1_o.jpg" rel="nofollow noreferrer">staticflickr.com</a>)</sub></p>
  <p>How do I fix this? For example, let's say I want to make the body panel 80% of the frame and the other two 10% each.</p>