Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7609987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:18:36+00:00 2026-05-31T01:18:36+00:00

I am not understanding why I am getting a runtime error when I try

  • 0

I am not understanding why I am getting a runtime error when I try to .setText() to a JTextArea Object in my program. In my main GUI class I have set up a event that creates a pop up JFrame object, this JFrame has a button in it which is set up too do a JTextArea.setText(); to a JTextArea in my main GUI class called MainOut.

public class GUI extends JFrame implements ActionListener {



JTextArea MainOut       =       new JTextArea(20,50);


public void actionPerformed(ActionEvent e) {


        if (e.getSource() == ExitVar){
            System.exit(0);
        }

        else if (e.getSource() == ServerLoginVar) { //This is my event that creates a 
                                                            //new JFrame popup
            new ServerLoginGUI(this);   
        } 

//-------------------------------------------------------------------
public class ServerLoginGUI extends JFrame implements ActionListener {

    JTextField ServerIP             = new JTextField(15);
    JPasswordField ServerPassword       = new JPasswordField(15);
    JPanel ServerLoginPanel         = new JPanel();
    JButton LoginButton         = new JButton("Login");
    JTextArea Area;
    JLabel ServerIPLabel            = new JLabel("Server Address:");
    JLabel ServerPasswordLabel      = new JLabel("Password      :");
    GUI GUi;
   public void actionPerformed(ActionEvent e) {

        if (e.getSource() == LoginButton){
            if (ServerIP.getText().isEmpty() ||  ServerPassword.getText().isEmpty()){
                } //do nothing

            else {
                new ServerAccess(this);

// this is the .setText() that will generate a error

                GUi.SiteNameField.setText("Test from the ServerLogin event!");

                dispose();}
                    }
        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:18:37+00:00Added an answer on May 31, 2026 at 1:18 am

    okay here is you problem. You have created the object of GUI in the ServerLoginGUI class. But you are not initializing your GUi object with the reference of calling class. Here is what you need to do to fix this. To your ServerLoginGUI class add the following constructor:

    public ServerLoginGUI(GUI gui)
    {
      this.GUi = gui;
    }
    

    Now your code should work fine and not give a run time error. Which I am assuming is a nullpointer error though you have not specified.

    PS: Please get the Java conventions right. Variables start with letter in lower case. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some not understanding actions from gnu clisp Suppose, I have some code
It's possible that I'm not really understanding how git works here, but I have
I'm just getting into the Asset Pipeline; I'm using SASS/SCSS, but I'm not understanding
I am getting following Error Java.io.IO.Exception; there is not enough space on the disk
I am not understanding the point of using .def files with DLLs. It seems
I am not understanding the 'aligning allocated memory' part from the mprotect usage. I
There's something wrong with my code or I'm just not understanding this fully. I
We're using ReportBuilder 1.0 (2005) for now. I'm not understanding the way that the
I found the following code somewhere, but I am not understanding the code properly.
i want to download ruby on rails, but i am not understanding what to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.