title: NullPointerException when transferring String between two GUI class
body: <p>I have a table and that it is my <code>editButton</code> action method:</p>
  
  <pre><code>    public void editAction() {
      if (table.getSelectedRow() &gt; -1) {
          String oldFName = table.getValueAt(table.getSelectedRow(), 1).toString();
          String oldLName = table.getValueAt(table.getSelectedRow(), 2).toString();
          String oldGender = table.getValueAt(table.getSelectedRow(), 3).toString();
          System.out.println(oldFName);  // prints correctly
          System.out.println(oldLName);  // prints correctly
          System.out.println(oldGender);  // prints correctly
  
          AddUserDialog userDialog = new AddUserDialog(this, oldFName, oldLName, oldGender);
      } else JOptionPane.showMessageDialog(null, "Select A Row");
  }
  </code></pre>
  
  <p>My AddUserDialog Class:</p>
  
  <pre><code>    public AddUserDialog(JFrame owner, String oldFname, String oldLname, String oldGender) {
      super(owner, "Edit User Information", true);
      fNameTf.setText(oldFname);     // First name text field
      lNameTf.setText(oldLname);     // Last name text field
      if (oldGender.equals("Male")) maleRb.setSelected(true);  //Male radio Button
      else femaleRb.setSelected(true);                   //Female radio Button
  
      setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      setLocation(400, 100);
      setVisible(true);
      pack();
  }
  ...
  }
  </code></pre>
  
  <p>Now, When i select a row and click to edit button, old first name and old last name and old gender prints correctly on my console , But My IDE say that exception is here:</p>
  
  <pre><code>fNameTf.setText(oldFname);       // why is Null here?!
  </code></pre>
  
  <p><strong>Update</strong>
  Second way:</p>
  
  <pre><code>    public void editAction() {
      if (table.getSelectedRow() &gt; -1) {
          String oldFName = table.getValueAt(table.getSelectedRow(), 1).toString();
          String oldLName = table.getValueAt(table.getSelectedRow(), 2).toString();
          String oldGender = table.getValueAt(table.getSelectedRow(), 3).toString();
          System.out.println(oldFName);  // prints correctly
          System.out.println(oldLName);  // prints correctly
          System.out.println(oldGender);  // prints correctly
          AddUserDialog userDialog = null;
  
          userDialog.setfName(oldFName);  // Why is null here?!
          userDialog.setlName(oldLName);
          userDialog.setGender(oldGender);
          userDialog = new AddUserDialog(this, userDialog.getfName(), userDialog.getlName(), userDialog.getGender());
  
      } else JOptionPane.showMessageDialog(null, "Select A Row");
  }
  </code></pre>
  
  <p>Now NullPointerException is here:</p>
  
  <pre><code>userDialog.setfName(oldFName);
  </code></pre>
  
  <p>How solve this?</p>