I trying to some formatting for my label in java swing. If user enter :
This
is
testing.
And I store this into database and retrieve out. How can I make this prevent from auto joining into one sentence. For example, I want this to be shown on my label which is scrollable :
This
is
testing.
instead of Thisistesting. I do not know what is this called. Is this the line wrap method? I added this : jLabel_reply.setLineWrap(true); into my code but no luck. The sentence is still auto joined together. Any guides? Thanks in advance.
JLabeldoes not display itself on multiple lines by default.You have two options here:
1) Use a non-editable, non-opaque
JTextArea2) Use HTML inside your
JLabeland replace all your line separators with<br>Basic example illustrating my saying: