JTextArea: how to wrap text by words, not characters?

前端 未结 3 1474
时光取名叫无心
时光取名叫无心 2021-01-07 16:44

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 JTextA

3条回答
  •  萌比男神i
    2021-01-07 17:13

    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 instead of linewrap Syntax - JTextArea.setwrapstyleword(true);

    Note~ It can only be used when you linewrap is already true I hope it would help.

    Source ~ My notebook

    Credits - 49/51 { 49% to myself & 51% to my ip teachers Ms. Shalu }

    ~ AM 17

提交回复
热议问题