问题
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