Sorting JTable on more than just the values listed in the columns
Posted on
16th Feb 2014 07:03 pm by
admin
I have a collection of objects that store (among other things) two integer values. I only want to display one of these values. The displayed value will dictate the sort order of the JTable.
However, I want to break ties with the other, undisplayed, integer value.
Did you know?Explore Trending and Topic pages for more stories like this.
I've gone through the trouble of specifying my own Comparator for the TableRowSorter. However, this method doesn't have access to the row index into the table. It is only passed the values in the column that is being sorted, not their position in the column. Without having a reference back to the row index (which I use as an index to the collection of objects) I cannot get the secondary value, unless I also display this value in its own column and sort on Sort Keys.
I don't want to do that, because I feel it clutters up the look of the table.
For example, I have the two sets of numbers
Row Name | Displayed Value | Undisplayed Value
rowA | 7 | 3
rowB | 7 | 5
With this set of data, rowB should be listed above rowA. Any ideas on how to implement this.
I'm pretty new to Swing, so there could be something simple that I'm missing (hopefully).
No comments posted yet
Your Answer:
Login to answer
296
12
Other forums
Inserting a variable in a link
I have this code that I want to insert for my own variable but I have no idea how. This is what I wa
LOOPing Problem
Hello All!
The following code loops through the data and displays the data accordingly. My p
All possible combinations of String in PL/SQL
Hi All,
Could you please explain the logic of getting all possible combinations of String
PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator
php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way
COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i
Multiple submit forms inside a mysql array page
Hi all,
Im having trouble to get the beneath script to work the thing i can't seem to get wor
php multiple action on submit
I have a form which says:
<form enctype='multipart/form-data' method='post' action='pr
Results from Db outputted twice
Hey guys.. for come reason my data is outputted twise shown in the image below and i cant figure out
Where am I going wrong
Been trying to work this out for hours
I have two tables called 'Genres' and 'Films'. Genre