• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Tutorial Table Sorter

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I personally would not risk.
 
Leszek Zajac
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then, did you implement your table sorter or did you implement sorting in table model?
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neither, my requirements don't mention sorting, only filtering.
And that's performed at database level.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)...
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic