title: JPanel not working with setSize & setPrefferedSize
body: <p>Please explain why it does not work, also could you post a solution to solve this issue. Thank you very mucho in advance.</p>
  
  <pre><code>public class Run extends JFrame{
  
      /** Fields **/
      static JPanel jpanel;
      private int x, y;
  
      /** Constructor **/
      public Run() {
          /** Create &amp; Initialise Things **/
          jpanel = new JPanel();
          x = 400; y = 400;
  
          /** JPanel Properties **/
          jpanel.setBackground(Color.red);
          jpanel.setPreferredSize(new Dimension(20, 30));
  
  
          /** Add things to JFrame and JPanel **/
          add(jpanel);
  
          /** JFrame Properties **/
          setTitle("Snake Game");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setCursor(null);
          setResizable(false);
          setSize(new Dimension(x,y));
          setLocationRelativeTo(null);
          setVisible(true);
      }
  
      /** Set the Cursor **/
      public void setCursor() {
          setCursor (Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
  
      /** Main Method **/
      public static void main(String [ ] args) {
          Run run = new Run();
          run.setCursor();
      }
  }
  </code></pre>