I have an message that needs to be displayed in that text area, but it is generated by code in Class B. I got an error message that I cannot use a non-static variable in a static context, so I created an instance of Class A and its text area within Class B :
A button triggers the cancel() function in Class B. I know that works because the system will print out the message, but the text area will not. What am I missing?
Are you sure you can compile this? What's the event in your method, I can't see you declared it and what is the purpose of that cancel() method on event object?
I suppose that A reference in your B class is not the frame you are actually displaying to the user and the one that contains the button handling the event. So what you're actually doing is just create new A frame, do something with it, but since it's not the one that is displayed you can't see the result of the action. It's a variable local to that method in B class.
Why don't you declare method in class B to return a String (message that's to be appended to your JTextArea)? Invoke that method on object of B class from event handler in class A to get the message as String and append it where needed.
The quieter you are, the more you are able to hear.
Destiny's powerful hand has made the bed of my future. And this tiny ad: