I am new to swings,my requirement are 1. I need to create a rowheader for the jtable. 2. Add up and down buttons (listeners for moving/changing the row position). 3. when I change the row position I should not change the rowheader number. 4. Need to retrieve the row data based on the rowheader index . 5. Already one userdefined class extend jtable and model is there with data.I need to add the above 4 points requirements to this table.I need to use Jlist or again jtable for adding rowheader(if again jtable then basic jtable with data is not working properly.) I tried with many google references,but the problem is I could not integrate all the functionalites at same time and even I could not find the solution for points 3 and 4.Please do consider the requirement.Sorry for typo mistakes. Thank in advance.

1

There are 1 best solutions below

5
On

I need to create a rowheader for the jtable.

Check out the Fixed Column Table.

You create a normal TableModel. Then you can specify the first row of the model to be used as the row header. The code will then create two table that share the same TableModel. One table will be used as the row header, the other will be displayed in the viewport of the scroll pane.

If you want to sort the tables you will then also need to share the RowSorter with code something like:

table.setAutoCreateRowSorter(true);
fct.setRowSorter(table.getRowSorter());
table.setUpdateSelectionOnSort(true);
fct.setUpdateSelectionOnSort(false);