A JTable where number of columns in each row may be different

独自空忆成欢 提交于 2019-12-12 18:09:42

问题


I am looking for a solution for a JTable where I can vary the number of columns in each row, but where the size (in pixels) of the row is constant.

I found stackoverflow referencing so far only dead-links to an old solution:

JTable with varying number of columns per row

Is there a newer better way to do it now ? If so, what? If not, does anyone know what the old solution was?

thanks.


回答1:


Does anyone know what the old solution was?

The examples, which appear to have been created for a Swing beta release in the last millennium, may be found here. You may be looking for MultiSpanCellTable. They may be a useful object of study, but they are not current. YMMV.




回答2:


I would create a renderer (panel with multiple fixed size labels or even multiple panels for each type of row).

It should be one column in TableModel with the renderer applied.



来源:https://stackoverflow.com/questions/14241863/a-jtable-where-number-of-columns-in-each-row-may-be-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!