title: EventQueue error when passing variables between two JFrames
body: <p>I'm attempting to pass a string between two <code>JFrame</code> objects in Java, a login form and a menu.</p>
  <h2>Login Code:</h2>
  <pre><code>String username;
  username = dbUser;
  this.setVisible(false);
  new Menu(username).setVisible(true);`
  </code></pre>
  <p>and in the menu form, I have an override to instantiate the class with the string</p>
  <pre><code>public class Menu extends javax.swing.JFrame {
  
  private Component frame;
  String user;
  
  public Menu() {
      initComponents();
  }
  
  public Menu(String User) {
      user = User;
      lblCurrent.setText(&quot;Current User: &quot; + user);
      initComponents();
  }
  </code></pre>
  <p>Now, in the public static void main which Netbeans creates, along with the look and feel code, it had an event handler which creates the form.</p>
  <pre><code>public static void main(String args[]) {
      /* Set the Nimbus look and feel */
             /*OMMITED FROM THIS*/
  
      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() {
          @Override
          public void run() {
              new Menu().setVisible(true);
          }
      });
  </code></pre>
  <p>No matter what I do, I can't add an override function to this, to accept a string and make this work, and as a result when the form gets created by the login form, I get this error:</p>
  <pre><code>Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException
      at Menu.&lt;init&gt;(Menu.java:26)
      at Login.btnLoginActionPerformed(Login.java:213)
      at Login.access$000(Login.java:21)
      at Login$1.actionPerformed(Login.java:54)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
      at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
      at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(BasicRootPaneUI.java:208)
      at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1664)
      at javax.swing.JComponent.processKeyBinding(JComponent.java:2878)
      at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:307)
      at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:250)
      at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2970)
      at javax.swing.JComponent.processKeyBindings(JComponent.java:2962)
      at javax.swing.JComponent.processKeyEvent(JComponent.java:2841)
      at java.awt.Component.processEvent(Component.java:6282)
      at java.awt.Container.processEvent(Container.java:2229)
      at java.awt.Component.dispatchEventImpl(Component.java:4861)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
      at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
      at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
      at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
      at java.awt.Component.dispatchEventImpl(Component.java:4731)
      at java.awt.Container.dispatchEventImpl(Container.java:2287)
      at java.awt.Window.dispatchEventImpl(Window.java:2719)
      at java.awt.Component.dispatchEvent(Component.java:4687)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
      at java.awt.EventQueue.access$200(EventQueue.java:103)
      at java.awt.EventQueue$3.run(EventQueue.java:694)
      at java.awt.EventQueue$3.run(EventQueue.java:692)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
      at java.awt.EventQueue$4.run(EventQueue.java:708)
      at java.awt.EventQueue$4.run(EventQueue.java:706)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
  Java Result: 1
  </code></pre>
  <p>Now I'm probably messing something up totally, or something is going straight over my head, but I'd appreciate if someone could point out the stupid mistake I'm making. I've never used Netbeans before and I've never seen this error before T_T.</p>