Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTable column spanning

Tags:

java

swing

jtable

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 JTables this won't be a problem, and any other solution would have to take this into consideration as well.

like image 887
Elie Avatar asked Sep 28 '08 19:09

Elie


People also ask

How do you make a JTable column not movable?

setReorderingAllowed() method and set the value as false.

What is JTable in swing?

The JTable class is a part of Java Swing Package and is generally used to display or edit two-dimensional data that is having both rows and columns. It is similar to a spreadsheet. This arranges data in a tabular form.

What is the purpose of JTable?

The JTable is used to display and edit regular two-dimensional tables of cells.


1 Answers

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.

like image 140
cgull Avatar answered Sep 23 '22 13:09

cgull