Excepción en el hilo "AWT-EventQueue-0"?

Estoy trabajando en un programa de calculadora simple usando java y javax.swing

ásicamente, cuando presiona un botón, el programa debe buscar la función de ese botón (número u operación) y mostrarlo en el área de texto.

Toda la lógica de la calculadora en sí misma no importa. Además, hay unaclar elemento de menú que borra todo el texto en textArea.

Sin embargo, cada vez que presiono un botón, aparece el siguiente error:

Exception en el hilo "AWT-EventQueue-0" java.lang.NullPointerException en calculator.CalculatorGUI.actionPerformed (CalculatorGUI.java:106)

También recibo un error similar cuando presiono laclar elemento del menú, parece que a Java no le gusta cuando quiero cambiar el texto en el área de texto.

Aquí está mi código: Line 106 está en elactionPerfomed método, lo he etiquetado para su conveniencia)

public class CalculatorGUI implements ActionListener 
{

    // The calculator for actually calculating!
    // private RPNCalculator calculator;

    // The main frame for the GUI
    private JFrame frame;

    // The menubar for the GUI
    private JMenuBar menuBar;

    // The textbox
    private JTextArea textArea;
    private JScrollPane scrollArea;

    // Areas for numbers and operators
    private JPanel numKeysPane;
    private JPanel opKeysPane;

    private String input;
    final String[] numbers = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
    final String[] operations = { "+", "-", "*", "/" };

    /**
     * Constructor
     */
    public CalculatorGUI() {
        // Initialize the calculator
        calculator = new RPNCalculator();
    }

    /**
     * Initialize and display the calculator
     */
    public void showCalculator() {

        String buttonValue;
        JButton button;
        JMenu menu;
        JMenuItem menuItem;

        // Create the main GUI components
        frame = new JFrame("RPN Calculator");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        numKeysPane = new JPanel(new GridLayout(4, 3));
        opKeysPane = new JPanel(new GridLayout(2, 2));

        initializeMenu();
        initializeNumberPad();
        initializeOps();


        JTextArea textArea = new JTextArea();
        textArea.setEditable(false);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        JScrollPane scrollArea = new JScrollPane(textArea);

        // Create the components to go into the frame and
        // stick them in a container named contents
        frame.getContentPane().add(numKeysPane, BorderLayout.CENTER);
        frame.getContentPane().add(scrollArea, BorderLayout.NORTH);
        frame.getContentPane().add(opKeysPane, BorderLayout.LINE_END);

        // Finish setting up the frame, and show it.
        frame.pack();
        frame.setVisible(true);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    public void actionPerformed(ActionEvent e) {
        String s = (String)e.getActionCommand();
        // calculator.performCommand(s);
        textArea.append(s + " ");      // <<--- THIS IS LINE 106
    } 

    /**
     * Initialize the number pad for the calculator
     */


    private void initializeNumberPad() {
        JButton button;
        for (int i = 0; i < numbers.length; i++) {
            button = new JButton(numbers[i]);
            button.addActionListener(this);
            numKeysPane.add(button);
        }
    }

    private void initializeOps(){
        JButton button;
        for (int i = 0; i < operations.length; i++){
            button = new JButton(operations[i]);
            button.addActionListener(this);
            opKeysPane.add(button);
        }
    }

    /**
     * Initialize the menu for the GUI
     */
    private void initializeMenu() {
        JMenu menu;
        JMenuItem menuItem;
        JMenuItem menuItem2;

        // Create a menu with one item, Quit
        menu = new JMenu("Calculator");
        menuItem = new JMenuItem("Quit");
        // When quit is selected, destroy the application
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // A trace message so you can see this
                // is invoked.
                System.err.println("Close window");
                frame.setVisible(false);
                frame.dispose();
            }
        });
        menuItem2 = new JMenuItem("Clear");
        menuItem2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                textArea.setText("");
            }
        });
        menu.add(menuItem2);
        menu.add(menuItem);

        // Create the menu bar
        menuBar = new JMenuBar();
        menuBar.add(menu);
        frame.setJMenuBar(menuBar);
    }

    /**
     * Helper method for displaying an error as a pop-up
     * @param message The message to display 
     */
    private static void errorPopup(String message) {
        JOptionPane.showMessageDialog(null, message);
    }
}

¡Cualquier ayuda sería muy apreciada! ¡Gracias

Respuestas a la pregunta(2)

Su respuesta a la pregunta