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.
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
Procedural to OOP
ohn Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pri
DYNPRO_FIELD_CONVERSION
Hi gurus,
I got a dump when I run one of my program. the dump is described below:
Log $_POST
How would i log submits on a form, by everyone? I want to then echo the number of submissions.
Port scanner problem
Hai
recently i developed one app through which u can check the opened and closed ports under an
eregi to preg
Im converting my regex for php 5.3 and I am stuck on the following
Code: [Select]if((eregi(&q
Javascript or not?
How many people prefer javascript/ajax sites? How many prefer the good old fashion straight php sit
upload only text files
hi guys i want to upload only text like like (pdf,note pad and ofiice files) so can any one please t
Adding Outlook 2007 items via file upload
I am looking for a way to be able to attach an Outlook item (an email message) in an ASP.NET 3.5 app
Connecion issue
Hi,
For some reason, I keep getting this error when trying to connect:
Warning: mysql_
Web Application Recipe
Hi Guys!
I am working with the Web Application recipes. I am currently working on the sen