JTextArea: how to wrap text by words, not characters?
问题 I want to avoid an output like this: Here is some text t hat is being wrappe d by characters, sp litting words in ha lf I am using a JTextArea, with setLineWrap(true). How can I make it wrap words, though? (Is there a way to make it only wrap when there is a space or something?) 回答1: JTextArea.setWrapStyleWord(true) ? 回答2: If you want your text is wrapped by words and not by the characters ( in other words , if you want you half word also shifts to next line Very simple just use wrapstyleword