JTable - wrap text in multiple cells
I know how to implement a wrapping cell renderer, but all popular implementations break when you have multiple wrapping columns. They set row height on demand, but this way one column can override another one's settings. Usual开发者_如何学Goly it's de facto the last column what determines row height.
E.g. for this data:
| Fairly lengthy text | Shorter Text |
If you shrink the second column you get:
| Fairly lengthy text | Shorter |
| | Text |
What is just fine, but if you shrunk the first column, you could get:
| Fairly lengthy | Shorter Text |
Second row is not displayed because "Shorter Text" overrode preferred height.
How can I implement this without creating cross-references and stack overflow? Do you know any ready-to-use implementations?
Resolved it myself. I memoized individual cell heights in a map and calculated row maximum each time a cell was rendered.
精彩评论