tags:

views:

32

answers:

1

Is there a way to merge column headers on click of a button but the values in the cell should get appeneded with each other?

For instance:

10      15      20     25     30
A       B       C      D      E
B       C       D      A      E

10              20            30
AB              CD            E
BC              DA            E

Actually the value A represents 10-15 B represents 15-20 and so on.Is this possible in JTable? Please don't confuse my earlier question with this.Here we try to merge two column headers not cells at the same time we append the values of the cell.

+1  A: 

You can do whatever you want using the getValueAt(...) and setValueAt(...) methods.

So you get the values of the two columns and combine them into a single string and then reset the value in the first column. Then you set the second column to the empty string.

camickr