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
I need some help with the IF command...
I have a large number of images in one section of my website with the .jpg format. I'm adding a bun
Count of reciepients in php mailer
How can i sent a mail to large no of reciepients say 10,00,00 Using PHP MAILER
IIS & NW MII on the same server
Hi,
We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server
Revoking alter any table from a schema
Hi All,
i am working in Oracle 10g.
my requirement is to revoke all kind of DDL oper
php mysql script to find record
Hi,
Currently I have a simple table with 4 columns. A, B, C, D
If I want to find all
Install page
How do I make it so when a user submits information on the Install page, it'll right it into the cor
RadioButtonList item spacing
I have a RadioButtonList and I can't put any spacing between the items. They are arranged verticall
how to validate date using javascript
I need to validate date in textbox using javascript..
The date is must be not greater than TODAY
Preg_match question
I want to use preg_match to make sure a string is always 6 characters long and only contains 0-9 and
in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)
Examp