java – Exception in thread AWT-EventQueue-0?

java – Exception in thread AWT-EventQueue-0?

You dont 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();.

java – Exception in thread AWT-EventQueue-0?

Leave a Reply

Your email address will not be published.