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
Error when call dll from oracle
Hi all, please help me!
I have dll write C language, I want call it from oracle procedur
How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor
try catch error
I have been trying try catch but, I can't get it to work. The code opens a non existing file called
Login script (probably a simple error)
dbConfig.php
Code: <?
// Replace the variable values below
// with your specific dat
Not showing whole name with mail () script
I sent up a simple mail form with the PHP mail() script. One problem is when it sends an email with
Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re
Namespace Problem
I'm having problem with a section of code with a variable namespace.
This code works fine:
split values
I have values that are returned to me in this format:
name=>test,age=>49
Check Digits and extracting digits
I think I can figure out the code for this but I am having a very hard time getting past the first s
PHP hyperlinks generator - HELP plz
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500