开发者

How to implement jtable with variable row-height

开发者 https://www.devze.com 2023-01-16 07:31 出处:网络
None of the answers to two previ开发者_如何学编程ous questions (here and here) resolve my problem.

None of the answers to two previ开发者_如何学编程ous questions (here and here) resolve my problem.

I have a multi-column jtable for which I want to display string-content of some columns over more than one line within the cell based on newline char's ("\n") within the string. The number of newlines per string is random, known only at run-time. Only the affected row must be adjusted across all columns to the new height. There may be a different number of lines per affected column, and the row-height needs to be adjusted to the maximum height of these, across the columns.

How do I do this?

If possible some sample code would be very much appreciated.

TIA


If I got you right, I think you need a MultilineCellRenderer . There are already plenty of examples around. Normally they are based on a JTextArea to get the line wrap functionality.

I haven't used it myself yet, but here is an example, which looks kinda good at first view:

MultilineCellRenderer

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号