Skip to main content

Trying to layout variable-height text in a ListCellRenderer

No replies
Joined: 2003-06-10

I'm trying to do something which looks very simple: I've got a few fixed size labels and whatnot in a list cell renderer, and one JTextArea.

What I'd like to occur is that the JTextArea fills up the remaining width of the cell renderer, and displays a minimum of 1 line of text, and a maximum of 4 lines of text, and that the cell renderer is the appropriate height.

Whatever I do, I can't get the JTextArea to size itself correctly.

I've tried SpringLayout (no success) and GridBagLayout (no success) and tried putting the JTextArea inside a JScrollPane and playing with the scrollable tracks viewport flags but again, no success.

Has anyone got a code snippet that'll manage this for me?

Cas :)