Elie Elie - 10 days ago 6
Java Question

JTable column spanning

I am trying to make a

JTable
that has column spans available. Specifically, I am looking to nest a
JTable
inside another
JTable
, and when the user clicks to view the nested table, it should expand to push down the rows below and fill the empty space. This is similar to what you see in MS Access where you can nest tables, and clicking the expand button on a row will show you the corresponding entries in the nested table.

If someone knows of a way to perform a column span with
JTable
, can you please point me in the right direction? Or if you know of an alternative way to do this, I am open to suggestions. The application is being built with Swing. Elements in the table, both high level and low level, have to be editable in any solution. Using nested
JTable
s this won't be a problem, and any other solution would have to take this into consideration as well.

Answer

As a pointer in the right direction, try this article at SwingWiki that explains the TableUI method of column spanning quite well. Before this, I also tried some alternatives such as overriding the TableCellRenderer paint methods without much success.

Comments