Java Swing TextArea unexpected attitude

48 views Asked by At

When I call this method inside class, works. When I call it outside of the class, TextArea doesn't change. While string values are correct.

public void printMessage(String prefix, String message) {
         System.out.println(prefix + message); // works
         textArea1.setText(textArea1.getText() + prefix + " " + message + "\n"); // works only if called from this class
    }
1

There are 1 answers

0
Jaqen K'uba On

Solved by myself. There was no problem with this code. I didn't initialize instance of this class properly.