TheNickmaster21
TheNickmaster21

Reputation: 275

Propper JTextArea Text Wrappping

I currently use this class to put text into a 'log' JTextArea:

public void appendOutput(String output) { 
    textPane.setText(textPane.getText() + "\n " + output); 
}

This works pretty well except for the fact that a text wrapping JTextArea will cut words in half. Is there a good/easy fix for this?

This is what it does...

Upvotes: 0

Views: 46

Answers (1)

bknopper
bknopper

Reputation: 1243

JTextArea.setWrapStyleWord(true)

So in your case it would be:

textPane.setWrapStyleWord(true);

Upvotes: 3

Related Questions