title: Intellij, "contentPane cannot be set to null" using swing designer
body: <p>I'm trying out intellij, and am trying to do some swing development. I am running into an issue I have never experienced on eclipse, and I am wondering if I have something set up wrong.</p>
  
  <p>Here is my GUI class that is run by my driver:</p>
  
  <pre><code>package view;
  
  import javax.swing.*;
  import java.awt.*;
  
  public class View {
  
  private JPanel panel;
  
  public void run() {
      JFrame frame = new JFrame("Vending Machine");
      frame.setContentPane(new View().panel);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setVisible(true);
  }
  
  {
  // GUI initializer generated by IntelliJ IDEA GUI Designer
  // &gt;&gt;&gt; IMPORTANT!! &lt;&lt;&lt;
  // DO NOT EDIT OR ADD ANY CODE HERE!
      $$$setupUI$$$();
  }
  
  /**
   * Method generated by IntelliJ IDEA GUI Designer
   * &gt;&gt;&gt; IMPORTANT!! &lt;&lt;&lt;
   * DO NOT edit this method OR call it in your code!
   *
   * @noinspection ALL
   */
  private void $$$setupUI$$$() {
      final JPanel panel1 = new JPanel();
      panel1.setLayout(new GridBagLayout());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>as far as I can tell, my run() method is as straightforward as it gets. However, upon compiling, this is the error I receive:</p>
  
  <pre><code>Exception in thread "main" java.awt.IllegalComponentStateException: contentPane cannot be set to null.
  at javax.swing.JRootPane.setContentPane(JRootPane.java:621)
  at javax.swing.JFrame.setContentPane(JFrame.java:698)
  at view.View.run(View.java:13)
  at model.VendingMachine.&lt;init&gt;(VendingMachine.java:14)
  at controller.Driver.main(Driver.java:14)
  </code></pre>
  
  <p>For whatever reason, the intellij autocreated code that does not properly initialize the JPanel, which is why it's null.</p>
  
  <p>I've tried instantiating it myself inside run (panel = new JPanel();) but that has not helped.</p>
  
  <p>Is this something obvious? I've never run into this issue when getting started with swing in eclipse.</p>