Appending text in Java's JTextArea

后端 未结 3 1961
梦如初夏
梦如初夏 2020-12-21 01:34

I have a problem with my text area.

I use jTextArea1.append(\"cleverly amusing\"); to add the text..

FIRST APPEND:

相关标签:
3条回答
  • 2020-12-21 02:13

    Why not use setText(String text) instead of append(String text)?

    0 讨论(0)
  • 2020-12-21 02:23

    Instead of removeAll, just call setText() with the first line you want and then you can append the additional data if you want.

    0 讨论(0)
  • 2020-12-21 02:27

    If your JTextArea will only contain "WORD HINT: ..." then use the setText() method:

    jTextArea1.setText("WORD HINT:\n" + word);
    

    This will replace all the text with what you want.

    BTW : removeAll() is part of the Container class, and is not to remove text but child components.

    0 讨论(0)
提交回复
热议问题