aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Java Tutorial Table Sorter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Java Tutorial Table Sorter" Watch "Java Tutorial Table Sorter" New topic
Author

Java Tutorial Table Sorter

Leszek Zajac
Greenhorn

Joined: May 18, 2006
Posts: 19
Hello.

Can I include slightly modified TableSorter class from Java tutorial in my project?
They say that all the code must be written by myself,
but on the other hand TableSorter may bee freely used.


Leszek
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Well, I personally would not risk.
Leszek Zajac
Greenhorn

Joined: May 18, 2006
Posts: 19
Then, did you implement your table sorter or did you implement sorting in table model?
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Neither, my requirements don't mention sorting, only filtering.
And that's performed at database level.


42
josine wilms
Ranch Hand

Joined: Jan 23, 2006
Posts: 45
Hi,

Me neither too. It's on a "nice-to-have-but-not-required list", but the reqs specify that too much work is not rated better, but you do risk minus points for a not so good implementation. Anyway there are no real world customers for this small application and I think that's a good case

Anyway there are lots of places where you can find algorithms for the table sorting!
To say to copy or not to copy: I also read Monkhouse's book and I have copied quite a few things from it, enhanced it, took stuff away. But then, if you look at other examples on the internet or Sun's own learnng material or books, you 'll find that in the end lots of it is just about the same. Only in Monkhouse's book it's more 'together packed' How could it be too different, it's all Java classes / functions ?

[ October 25, 2006: Message edited by: josine wilms ]
[ October 25, 2006: Message edited by: josine wilms ]

SCJP 1.4<br />SCWCD 1.4<br />SCJD <br />SCEA (new version) Work in progress...
Chulwoo Choi
Ranch Hand

Joined: Apr 11, 2005
Posts: 65
Hi,

Sorting is good to have and not difficult to implement. So why not install it in your UI?

In your table model, you should have an array or list for the data, say,

which is visually displayed in JTable.

To implement sorting:
First, you need to have a method (in your table model class) that sorts your data list (see dataList above). For example,

Second, this method will be called when you click on a table column header so add MouseListener to table header. The mouseClicked method of the listener will call the sort method. Note you should convert table's column index to the model's (using JTable's convertColumnIndexToModel method) when calling the sort method.

Regards,
Chulwoo
Leszek Zajac
Greenhorn

Joined: May 18, 2006
Posts: 19
Hi.

The problem is not in implementing sorting.
I have done it in my table model.
I have just thought of improving my design
and implementing sorting as separate class.
And such a class is already written,
so why should I reinvent the wheel.

But as you all said it's "nice to have/not required" feature
and I don't want take the risk,
so I'll stay with sorting in table model.
Petr Hejl
Ranch Hand

Joined: Feb 26, 2006
Posts: 68
For me the problem is:
When I want to implement TableSorter - through some design patterns you end with something very similar to TableSorter from tutorial. Ad thus it is hard to say if it is your work (but _it_is_ my work)...
Allan Jacobs
Greenhorn

Joined: Aug 28, 2006
Posts: 15
I'm very close to submitting. In my UI, I tried to follow the Java Look and Feel guidelines as closely as possible. JL&F is neutral on row sorting, so I probably did some extra work. I think I'll live dangerously and submit with a modification of the tutorial's table sorter. In a few weeks, I'll update this thread with notification of success or failure.

The tutorial's sorter did have some bugs in it. So, I did make some changes. I think it's appropriate to include Sun's copyright. If this was real code, would I need a second copyright to cover my fixes?
 
 
subject: Java Tutorial Table Sorter