1

I'm trying to update a JTextArea using the .append. I'm sending in a string to the method from another class and I know the textBox method gets the string as I can use .println to test it. The only thing is it does not update the JTextArea which is strange as when I first start the program and the gui is being created i'm able to update it.

public void textBox (String text){

    textArea.append(text);

}

Does anyone have any ideas? Many thanks in advance.

4

2 回答 2

0

Try using textArea.append(text + "\n"); I too had the same problem . I solved it by adding a "\n" at the end

于 2011-03-05T08:00:49.763 回答
0
JTextArea textArea = new JTextArea(text);
      textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        String appendText = "jumps over the lazy dog.";
       textArea.append(appendText);
于 2011-03-05T08:16:42.253 回答