Q:

Problems with receiving input from JButton

This is my Black Jack program, it's still a WIP but the program will run. The problem is that clicking the JButton hit will not .setText to the new value, stored in the JLabel total.  Someone please help!
import java.awt.Color;
import javax.swing.*;
import java.text.*;
import java.awt.Font.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class A3_Poltoranos_Max implements ActionListener{

  int playerCard1 = (int)(Math.random() * 11) * 1 + 1;
  int playerCard2 = (int)(Math.random() * 11) * 1 + 1;
  int totalScore = playerCard1 + playerCard1;``

  JPanel background;
  JLabel total, totalTitle;
  JButton hit, stand;

  public JPanel createContentPane(){
    JPanel totalGUI = new JPanel();    
    totalGUI.setLayout(null);

    JPanel background = new JPanel();
    Color feltGreen = new Color(27, 154, 25);
    background.setLayout(null);
    background.setBackground(feltGreen);
    background.setLocation(0, 0);
    background.setSize(800,600);
    totalGUI.add(background);

    JLabel totalTitle = new JLabel("Your total:");

    totalTitle.setLocation(150, 50);
    totalTitle.setSize(100, 40);
    totalTitle.setHorizontalAlignment(0);
    background.add(totalTitle);

    JLabel total = new JLabel(""+totalScore);

    total.setLocation(150, 200);
    total.setSize(100, 40);
    total.setHorizontalAlignment(0);
    background.add(total);

    JButton hit = new JButton("Hit!");
    hit.setLocation(50, 450);
    hit.setSize(100, 30);
    hit.addActionListener(this);
    background.add(hit);

    JButton stand = new JButton("Stand!");
    stand.setLocation(250, 450);
    stand.setSize(100, 30);
    stand.addActionListener(this);
    background.add(stand);

    totalGUI.setOpaque(true); 
    return totalGUI;  
  }
  @Override
  public void actionPerformed(ActionEvent e) {
        if(e.getSource() == hit)
        {
            playerCard2 = (int)(Math.random() * 11) * 1 + 1;
            totalScore = totalScore + playerCard2;
            total.setText(""+totalScore);
        }
        else if(e.getSource() == stand)
        {            
            total.setText(""+totalScore);
        }
    }

  private static void createWindow() {
    JFrame frame = new JFrame("Black Jack V 0.1"); 
    A3_Poltoranos_Max demo = new A3_Poltoranos_Max();
    frame.setContentPane(demo.createContentPane());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 600);
    frame.setVisible(true); 
  }
  public static void main(String[] args) { 
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
    createWindow();

      }
    });
  }
}

A:

You store the button in a local var "hit" instead of the object var "hit" - this is why the test
if(e.getSource() == hit)

will always fail (hit is null).
Do not declare a new variable and the code should work:
hit = new JButton("Hit!");

instead of 
JButton hit = new JButton("Hit!");

(same of course applies to the other buttons, labels and the panel, too.)

