update Swing Text Area in Thread - Java Swing

Java examples for Swing:JTextComponent

Description

update Swing Text Area in Thread

Demo Code


//package com.java2s;

import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

public class Main {
    public static void updateTextArea(final JTextArea textArea,
            final String text) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                textArea.append(text);/* w w  w . ja  v  a2  s . co m*/
            }
        });
    }
}

Related Tutorials