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.
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
Insert to MySQL inside foreach
Hey.
I am parsing some html, and putting inside an html db.
I need to create a randomized inte
SCRIPT ERROR
Here is the CONTACT FORM I made for our website:
<form id="form1" name="
Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on
php - xml what is the best way to do this.
IN essence I want to have a script calling the info from the database.. I have no problem thus far,
Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d
asking for direction
I have 2 tables in my data, which are "post" and "event"
I won't make a summa
Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th
please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php
ORA-00932: inconsistent datatypes: expected - got CLOB
SO : windows xp
database : XE
there is a table (transito) with two fields of clob
WELCOME SCREEN
first of all let me tell you what does my script do,
it´s a very simple query to show a e