title: error upon assigning Layout: BoxLayout can't be shared
body: <p>I have this Java <code>JFrame</code> class, in which I want to use a boxlayout, but I get an error saying <code>java.awt.AWTError: BoxLayout can't be shared</code>. I've seen others with this problem,  but they solved it by creating the boxlayout on the contentpane, but that is what I'm doing here. Here's my code:</p>
  <pre><code>class EditDialog extends JFrame {
      JTextField title = new JTextField();
      public editDialog() {
          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          setTitle(&quot;New entity&quot;);
          getContentPane().setLayout(
              new BoxLayout(this, BoxLayout.PAGE_AXIS));
          add(title);
          pack();
          setVisible(true);
      }
  }
  </code></pre>