title: Using Java pack() method
body: <p>I can't make the pack() method work. I tried several things. My code looks like this at the moment:</p>
  
  <p>Class 1:</p>
  
  <pre><code>public static void main( String[] args )
      {
      java.awt.EventQueue.invokeLater(new Runnable() {
          public void run()
          {
           JavaGui mygui = new JavaGui();
     //       mygui.setSize(1154, 753);
              mygui.setVisible(true);
              mygui.pack();
  </code></pre>
  
  <p>Class 2:</p>
  
  <pre><code>public class JavaGui extends javax.swing.JFrame 
      {
      public JavaGui()
          {
          getContentPane().setLayout(null);
          ..
          getContentPane().add(panelLeft);
          ...
          getContentPane().add(panelRight);
  </code></pre>
  
  <p>I tried putting the pack method in everywhere, but it's not going to work with this way of adding gui elements. Any suggestions why? I also tried adding everything to a JFrame instead of the getContentPane(), but I can't make that work either.</p>