title: The button doesn't work (GUI)
body: <p>I'm trying to make a bank account into a GUI, but the Buttons don't work because of the setText method. Nothing appear in the textarea.</p>
  
  <p>the Account class </p>
  
  <pre><code>public class Account {
      //attribute for balance amount 
      private double balance;
  
      // constructor to inital the  balance attribute
      public Account(double nitialBalance){
  
      if(nitialBalance &gt; 0.0)
          balance=nitialBalance;
      }
  
      // to add money method
      public void set_add_Balance(Double balance1){
          balance+=balance1;
      }        
  
     //  the withdrawn amount from the account
     public void depit(double debit){
          double f=0;        
          balance=balance-debit;
  
         if (balance &lt;= 0){
             f=debit;
             System.out.println("f=debit");
         }
         if(balance &lt;= 0){
             balance = balance + f;
             System.out.println("Debit amount exceeded account balance ");
         }
     }
  
     // to cheack the amount you have  
     public double getBalance( ){
          return balance;
     }
  
     // tostring for get balance
     public String toString(){
         return "Your Balance is : "+getBalance();
     }
  }
  </code></pre>
  
  <p>The GUI method </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  public class GUI extends JFrame {
      Account a;
  
      JButton j1=new JButton("Your Balance");
      JButton j2=new JButton("Add Money");
      JButton j3=new JButton("Withdrow Money");
      JButton j4=new JButton("Exit");
  
      TextArea t1=new TextArea("");
      Container cont = getContentPane();
  
      public GUI(){
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);          
          setTitle("Bank Account");
          setSize(500,300);
  
          JPanel p = new JPanel();
          p.setLayout(new GridLayout(2,2));
          p.add(j1);  p.add(j3);
          p.add(j2);  p.add(j4);
  
          cont.add(p,"South");
          cont.add(t1,"Center");
  
          j1.addActionListener(new buttons());
          j2.addActionListener(new buttons());
          j3.addActionListener(new buttons());
          j4.addActionListener(new buttons());
      }
  
      private class buttons implements ActionListener {        
          public void actionPerformed (ActionEvent e){        
              Object c =e.getSource();
  
              if(c==j1) {
                  t1.setText( "Your Balance is: "+a.toString());
              }        
              if(c==j2) {
                  a.set_add_Balance(50.0);
                  t1.setText( "Your Balance is: "+a.toString());
              }       
              if(c==j4){        
                  System.exit(0);
              }
          }// end of actionPerformed        
      }
  
      public static void main(String[] args) {
          GUI j=new GUI();
          j.setVisible(true);
      }        
  }
  </code></pre>
  
  <p>The problem occurs in the button 1 and 2 </p>
  
  <pre><code>if(c==j1) {
      t1.setText( "Your Balance is: "+a.toString());
  }    
  if(c==j2){    
      a.set_add_Balance(50.0);
      t1.setText( "Your Balance is: "+a.toString());
  }
  </code></pre>
  
  <p>I tried to fix it, but I don't know the cause of the program </p>
  
  <p>I added commend to the account class to make it easier to understand.</p>
  
  <p>Please lead me to the solution.</p>
  
  <p>Thank you very much in advance.</p>