如何用可变的行高实现jtable [英] How to implement jtable with variable row-height

查看:174
本文介绍了如何用可变的行高实现jtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前两个问题(此处

我该怎么做?
如果可能的话,将非常感谢一些示例代码.
TIA

如果我说对了,我认为您需要一个MultilineCellRenderer.周围已经有很多例子.通常,它们基于JTextArea以获得换行功能.

我还没有使用过它,但是这里有一个例子,它在第一眼看上去还不错:

MultilineCellRenderer

None of the answers to two previous 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

这篇关于如何用可变的行高实现jtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆