I have a JList, the list is filled with the elements of a file, I want the text within the elements to be adjusted to the size of the list, increasing the height of the cell and giving line breaks.
How could I do it?
I have a JList, the list is filled with the elements of a file, I want the text within the elements to be adjusted to the size of the list, increasing the height of the cell and giving line breaks.
How could I do it?

A list cell renderer (typically a
JLabel) supports HTML formatting, so we can use styles to set a body width. The height of the cell will adjust accordingly. The middle list uses a renderer that is constrained to 100 px width.That's three lists based on properties of the first thousand Unicode characters. Each list is as wide as it needs to be in order to display the widest string in the list model (however it is formatted for rendering).
Here is the MCVE: