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
MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro
puting for loop in 1 value
hi ,
how do i put this code in 1 value:
Code: <?php
for ($i=1; $i<=5; $i
Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?
Hashing?
Hi, I was hoping to take a string value then convert it - consistently - across each of our pages in
What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin
Checking if field is empty AND using !is_numeric
Hi lads,
Need to be able to display an error message (using isset?) that says "Cant lea
Data storage spaces in varchar2
Trying to understand what's happening.
I am selecting a value from a table that is defined as c
Undefined Variable: PHP_SELF, pls help
Hi,
Im a newbie on PHP / MySQL programming and Im running a script to search one field on my
Could Someone Please Debug This?
I was wondering if someone could debug this script for me. I realize it's not the tidest script (and
Need understanding of this bit of code
Code: <?php
// WHERE clause filters
$arrSQLFilters = array();
//