简体   繁体   中英

Java Swing TextArea unexpected attitude

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
    }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM