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
records between 2 dates
Hello all,
I have a date tracked table which contains effective_start_date and effective
Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not reall
Tracking Unique Clicks
Hi guys and gals,
Basically I have a database which tracks clicks on my outbound links, I do
Pls help with PHP
Pls can anyone direct me on how to create a user account for a customer. For example i want know if
Delete records not in top 15
Hi,
I'm creating a hall of fame page in my game and the page will only display the top 15 sco
Why use OOP?
Can someone explain to me why I should use OOP instead of procedure based code.
Im building a
Multi image upload
I have a gallery to build and want to build a dynamic upload form to allow for $var number of fields
Code Review - SQL and Insertion Attacks (Warning: Not for Newbs)
Hey guys,
Its been a while, I know. Use to love coming here to answer peoples questions, but
Confused with Loop
guys, i got confused with Looping...this is the case
I have 3 stocks, let say "Stock A&q
Problems generating word documents on server side for security reasons
I have a problem with word documentation generation when generating a word document (docx) with PHP.