Problem adding JTextField to Container

Okay Experts have another java problem.

I have a program that creates textfields that will be filled with user inputs once they press a "New Users" button. This I have managed to accomplish, but I am also supposed to create a field under the buttons that contains the same infomation. The Problem I am having is creating that field and filling it with the data.

Here is the snippet of code from the actionlistener for that button.
      public void actionPerformed ( ActionEvent event )
            if ( event.getSource() == btnNewUser )
                  JPanel centerLayout = new JPanel();
                  // Prompt User for Input
                  userName = JOptionPane.showInputDialog( "Please Enter Your Name." );
                  userAge = Integer.parseInt(JOptionPane.showInputDialog( "Please Enter Your Age.") );
                  // Determine User Gender
                  userSex = JOptionPane.showInputDialog( "Please Enter you Gender.\nM for Male\nF for Female");
                  if (userSex == "F")
                        userGender = "Female";
                        userGender = "Male";
                  userHeight = Integer.parseInt( JOptionPane.showInputDialog( "Please Enter Your Height" +
                              "\nIn Inches") );
                  userWeight = Integer.parseInt( JOptionPane.showInputDialog( "Please Enter Your Weight" +
                              "\n In Pounds") );
                  // Set Text In TextFields
                  nameField.setText( userName );
                  ageField.setText( "" + userAge );
                  genderField.setText( userGender );
                  weightField.setText( "" + userWeight );
                  heightField.setText( "" + userHeight );
                        // Create User Object
                  User user = new User( userName, userAge, userWeight, userSex, userHeight );
                  String displayOutput = userName
                  JTextField display = new JTextField (displayOutput);
                  c.add( centerLayout,BorderLayout.CENTER );
                  btnOldUser.setEnabled( false );

When I run the program and click the "New User" button it gives a null pointer exception at                    ---c.add( centerLayout,BorderLayout.CENTER );---
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


getContentPane().add( centerLayout,BorderLayout.CENTER );

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
(IOW you may not have assigned 'c' - so check it)
reefcrazedAuthor Commented:
That did it CEHJ, Thanks a ton!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.