Thread « Text Input « Java Swing Q&A





1. Java: mytextarea.setText("hello") + Thread.sleep(1000) = strange result    stackoverflow.com

I have something like this:

for(int i=0; i<5; i++){
    mytextarea.setText("hello " + i);
    try{
        Thread.currentThread().sleep(1000); //to give time for ...

2. Frequent calls to setText() in multithreaded Swing program    stackoverflow.com

I have a Swing program where work is continuously being done in a non-Swing thread. It often needs to update a JTextPane -- frequently many times per second. I realize that ...

3. Question about a recent thread: reading from a JTextComponent    java-forums.org

Well the point of my comment was that you can't just write out the entire string when you use getText(). If you use getText() then you would need to alter the String by replacing the "\n" using the suggestions above. Then you can write the text out using any means you want. It would not have to be a PrintWriter. However, ...