title: NullPointerException while opening new frame
body: <p>today I'm having a bit of a slight, see, I'm trying to run my code and I'm getting a NullPointerException. The clues in the exception leads me to this function right here:</p>
  
  <pre><code>private void irGuiJuego(JFrame frame){
      SwingConsole.run(new GUIJuego(), 800, 600, true);
      frame.dispose();
  }
  </code></pre>
  
  <p>Where SwingConsole would have this code:</p>
  
  <pre><code>package utiles;
  
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  
  public class SwingConsole {
  
      public static void run(final JFrame frame, final int width, final int height, final boolean exitOnClose) {
  
          SwingUtilities.invokeLater(new Runnable() {
  
              @Override
              public void run() {
  
                  if (exitOnClose)
                      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
                  frame.setSize(width, height);
                  //frame.setResizable(false);
                  frame.setVisible(true);
  
              }
          });
      }
  
      public static void run(final JFrame frame, final int width, final int height, final boolean exitOnClose, final String title) {
  
          SwingUtilities.invokeLater(new Runnable() {
  
              @Override
              public void run() {
  
                  if (exitOnClose)
                      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
                  frame.setTitle(title);
                  frame.setSize(width, height);
                  frame.setVisible(true);
  
              }
          });
      }
  
  
  }
  </code></pre>
  
  <p>It is kind of odd, considering that I'm using the same method to open up another frame, in this function to be specific: </p>
  
  <pre><code>private void volverMenuInicio(JFrame frame){
      SwingConsole.run(new MenuInicio(), 300, 150, true);
      frame.dispose();
  }
  </code></pre>
  
  <p>I'll leave you guys a pastebin of the GUIJuego Frame, since it's sort of excessive to post it here: <a href="http://pastebin.com/LSXbc7KE" rel="nofollow">http://pastebin.com/LSXbc7KE</a> , have the pastebin of the other frame too, in case you need it: <a href="http://pastebin.com/hbdd7j84" rel="nofollow">http://pastebin.com/hbdd7j84</a></p>
  
  <p>Edit: Here's the stacktrace, sorry for the lack of it before!</p>
  
  <blockquote>
    <p>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at java.awt.Container.addImpl(Unknown Source)   at
    java.awt.Container.add(Unknown Source)    at
    gui.GUIJuego.(GUIJuego.java:113)    at
    gui.MenuNuevoJuego.irGuiJuego(MenuNuevoJuego.java:95)     at
    gui.MenuNuevoJuego.access$2(MenuNuevoJuego.java:94)   at
    gui.MenuNuevoJuego$2.actionPerformed(MenuNuevoJuego.java:74)  at
    javax.swing.AbstractButton.fireActionPerformed(Unknown Source)    at
    javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)    at
    javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)    at
    javax.swing.DefaultButtonModel.setPressed(Unknown Source)     at
    javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
    Source)   at java.awt.Component.processMouseEvent(Unknown Source)     at
    javax.swing.JComponent.processMouseEvent(Unknown Source)  at
    java.awt.Component.processEvent(Unknown Source)   at
    java.awt.Container.processEvent(Unknown Source)   at
    java.awt.Component.dispatchEventImpl(Unknown Source)  at
    java.awt.Container.dispatchEventImpl(Unknown Source)  at
    java.awt.Component.dispatchEvent(Unknown Source)  at
    java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)     at
    java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)  at
    java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)  at
    java.awt.Container.dispatchEventImpl(Unknown Source)  at
    java.awt.Window.dispatchEventImpl(Unknown Source)     at
    java.awt.Component.dispatchEvent(Unknown Source)  at
    java.awt.EventQueue.dispatchEventImpl(Unknown Source)     at
    java.awt.EventQueue.access$200(Unknown Source)    at
    java.awt.EventQueue$3.run(Unknown Source)     at
    java.awt.EventQueue$3.run(Unknown Source)     at
    java.security.AccessController.doPrivileged(Native Method)    at
    java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
    Source)   at
    java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
    Source)   at java.awt.EventQueue$4.run(Unknown Source)    at
    java.awt.EventQueue$4.run(Unknown Source)     at
    java.security.AccessController.doPrivileged(Native Method)    at
    java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
    Source)   at java.awt.EventQueue.dispatchEvent(Unknown Source)    at
    java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
    Source)   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  at
    java.awt.EventDispatchThread.run(Unknown Source)</p>
  </blockquote>
  
  <p>Thanks for reading, by the way!</p>