title: Java - panel is the same size as frame
body: <p>I'm totally new at Java, and I'm trying to write my first program..</p>
  
  <p>But I've already run into the first problem that I can't seem to find the answar to at google.</p>
  
  <p>I have made a JFrame and a JPanel inside of it.</p>
  
  <p>I want the panel to be a specific size, but when I try to set the size of the panel, it doesn't work, and the panel just fits the size of the frame.</p>
  
  <pre><code>package proj;
  
  import javax.swing.*;
  import java.awt.*;
  
  class Program {
      Program() {
          JFrame frame = new JFrame("Mit program");
          frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
          frame.setVisible(true);
          frame.setSize(600, 400);
          frame.setResizable(false);
  
          JPanel panel = new JPanel();
          panel.setVisible(true);
          panel.setSize(100,100); // &lt;- Why doesn't this work?
          panel.setBorder(BorderFactory.createLineBorder(Color.black));
          frame.add(panel);
      }
  }
  
  public class Proj {
      public static void main(String[] args) {
          new Program();
      }
  }
  </code></pre>