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
Multiple Pages
Hi. Im very new to php. I'm trying to create a basic login/registration page.
So I have a bas
Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem
Local file browser with php
Halo..
So this is what i want to create. I have a folder that i share and it has many movies.
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi
please help me... my password gets encrypted but not able to get in database
hai guys,
please help me... in the following function my password gets encrypted but no
limit string by words??
hello all,
I was wonder if there is a function to limit a string by the number of words inste
post to self
Trying to get my form to submit to itself. However I am also trying to use an image for my submit bu
[PHP HELP] Php order form.
Hello to everyone @ phpfreaks. Im new to this site and hope to learn lots of things here.
Fir
Preventing SQL Injection
I have a question about SQL Injection, In some of our code we use this:
view plaincopy to clipboa
str_replace help
Hey there,
I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean