Exception in thread "AWT-EventQueue-0"?

You don't ever initialize the JTextArea member field called textArea. You are shadowing the member field in your declaration. Try this:

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

instead of

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

You are not creating the textarea object, JTextArea textArea = new JTextArea(); just defines a local variable in the showCalculator() that hides the class attribute that remains uninitialized, so use textArea = new JTextArea();.

Tags:

Java

Swing