I have a JTable, I Want to present a String of text containing "\r\n" which represent new lines. And I want these new lines to show in the table and not just be ignored.
A visual representation of my problem follows.
Today:
|Titel |
------------------
|texttex ttext xt|
------------------
Goal:
|Titel |
----------
|texttex |
|ttext xt|
----------
I have experimented with JTextPane but my result is a textual representation of that object instead of a text encapsulated in a JTextPane..(Maybe I don’t understand all those obvious internet guides).
To summarize the question, how do I present a column in a JTable which contains multiple lines without having a indexation for each line.
(or basic instructions of how to really make the JTextPane work in a column..?)
I would suggest either you use
<br>instead of\r\nor
you set a
TableCellRendereron yourJTable. TheTableCellRendererwould return aJTextPanewhen it is called – create only one instance ofJTextPaneand return it for each call (after having set the appropriate value)