title: How to access and change a JTextArea from another class
body: <p>I've been programming for quite a long time in PHP and other web programming languages but I'm really new to Java. And as I've been using a procedural approach when programming in PHP I'm quite new to OOP as well. Now I'm following a very basic Java tutorial.</p>
  
  <p>I have this code for displaying to different "bank accounts": </p>
  
  <pre><code>public class UseAccount extends JFrame {
  
  public static void main(String[] args) {
  
      Account myAccount = new Account();
      Account yourAccount = new Account();
  
      myAccount.name = "Jimmy";  
      myAccount.address = "Arjeplogsvägen 1";
      myAccount.balance = 1250.70;
  
      yourAccount.name = "Greg Giraldo";
      yourAccount.address = "Fishermans friend's 4";
      yourAccount.balance = -5820.30;
  
      myAccount.display();
      System.out.println();
      yourAccount.display();
  }
  }
  </code></pre>
  
  <p>And here is the "Account" class:</p>
  
  <pre><code>public class Account{
      String name;
      String address;
      double balance;
  
      void display() {
          System.out.print(name);
          System.out.print(" (");
          System.out.print(address);
          System.out.print(") has $");
          System.out.print(balance);
      }     
  }
  </code></pre>
  
  <p>This works really well. but now I want to output this information to a JTextArea. So I've written this code for the UseAccount class:</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class UseAccount extends JFrame {
          JTextArea output = new JTextArea();
  
      public UseAccount() {
          setLayout(new BorderLayout());
          add(output, BorderLayout.CENTER);
      }
  
      public static void main(String[] args) {
      UseAccount frame = new UseAccount();
      frame.setTitle("Account");
      frame.setSize(500,400);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
  
      Account myAccount = new Account();
      Account yourAccount = new Account();
  
      myAccount.name = "Jimmy";  
      myAccount.address = "Arjeplogsvägen 1";
      myAccount.balance = 1250.70;
  
      yourAccount.name = "Greg Giraldo";
      yourAccount.address = "Fishermans friend's 4";
      yourAccount.balance = -5820.30;
  
      myAccount.display();
      System.out.println();
      yourAccount.display();
      }
  }
  </code></pre>
  
  <p>And then I was trying to make the "Account" class extend the "UseAccount" class and then use output.append("the_text") for displaying the text. But this obviously doesn't work:</p>
  
  <pre><code>public class Account extends UseAccount{
      String name;
      String address;
      double balance;
  
      void display() {
          output.append(name);
          output.append(" (");
          output.append(address);
          System.out.print(") has $");
          System.out.print(balance);
      }     
  }
  </code></pre>
  
  <p>I did not change every system.out.print() to output.append as it isn't working anyway.</p>
  
  <p>I'm wondering how to access and change the text of my textarea("output") from this other class?</p>
  
  <p>I hope someone will be able to help me with this little problem.</p>
  
  <p><strong>I do know that similiar questions have been asked here earlier. And I have tried to look at the solutions given to those questions to solve my problem. But most of the other questions have been too complicated for me to understand what it was all about. Therefore I now try to post my own question.</strong> </p>