aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Jtable sorting; problem with getValueAt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Jtable sorting; problem with getValueAt" Watch "Jtable sorting; problem with getValueAt" New topic
Author

Jtable sorting; problem with getValueAt

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi guys,

I have implimeneted a sorting JTree (with a TableSorter).
Problem is when the user clicks on the column, say length, the sorting is incorrect. (it sorts it as if it's a String; same goes to the sort by dueDate)

I understand that the sorting is according to the object's type. the due date is a String in the example below but when converting to Date, the result is: Wed Aug 10 00:00:00 PDT 2005) (?!)

anyone knows how to correct this?
Thanks
Peter

Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Which table sorter are you using? I guess the one
from the JFC demo is the most common, but there
are a few out there.

Also, what are you doing in your implementation
of the getColumnClass() method?


bitguru blog
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
public String getColumnName(int column)
{
return names[column].toString();
}

protected TableModel dataModel = new AbstractTableModel()...
TableSorter sorter = new TableSorter(dataModel);
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
I asked about getColumnClass(), not getColumnName().
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
mmm, good question. I didn't implement it.
is this the source of the problem?

what should be returned?

public Class getColumnClass(int col)
{

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jtable sorting; problem with getValueAt