java JTable sort objects

745 views Asked by At

I am sorry for asking this. But I am having huge problems understanding how to do so.

I have a JTable. For that JTable I have my own AbstractTableModel that returns a custom object for getValueAt. Additionally I also have my own TableCellRenderer that uses a lot of colors, and uses column value to extract specified values from object that is given by getValueAt.

However I would like to be able to sort values. So how would I go about sorting? I would like to be able to receive the two objects, and the column, and sort based on that.

I tried reading bunch of tutorials but they show how to sort either based on string, or just sort without knowing the column.

Also should I be doing sorting in the class where I create the JTable, or in AbstractTableModel or in TableCellRenderer?

Any help or pointing to good tutorial will be greatly appreciated. I am sorry but I really suck at this worsting and have never done it.

0

There are 0 answers