Re: TableSorter.java v2.1
- From: ouroborus <ouroborus@xxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 17:25:23 -0700
Andrew McDonagh wrote:
> ouroborus wrote:
>> As part of another project, I spent some time updating
>> TableSorter.java so that it compiles cleanly under Java 1.5. The file
>> can be retrieved from:
>>
>> http://ouroborus.org/java/
>>
>> I would appreciate any constructive comments regarding the results.
>
> Where's the JUnit unit tests for it?
There aren't any. However, feel free to volunteer for this task.
> Why use reflcection to search for a method 'compareTo' when you could
> use instanceOf?
I'm not a programmer by profession. My knowledge in the areas relating
to reflection and related were very minimal a few days ago before I had
started working on this. Thank you for the idea though, I'll have to
look into this.
At my last company we tried all sorts of way of making the adapter work in all conditions and found the best approach for this task - is to use the same as JTable does for allowing columns to be moved by the user.
JTable & TableColumnModel keeps tract of where columns are and doesn't have any problems with any changes to the data, even whilst the columns are being moved.
We ended up create a derived JTable class - SortingTable.
It worked the tree and with surprisingly little code.
> see http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html#convertColumnIndexToView(int)
>
> We realized the problem with adapting the TableModel, was that we were
> trying to make our Model presentable. Whereas in the MVC pattern that
> JTable (tries) to use the model should remain unaware of how its viewed.
> So by putting the presentation logic in the JTable itself this not only
> made more sense from the design pattern point of view (JTable is a mix
> of the controller and view) it also worked in a far easier manner.
Now that you mention it, it seems that was/is my problem to. I'm glad you
said this as it presents me with a new view of this whole thing. My
initial goal was to simply make TableSorter work and compile without
warnings. Since it turned out to be reasonably presentable, I decided to
post it.
.
- References:
- TableSorter.java v2.1
- From: ouroborus
- TableSorter.java v2.1
- Prev by Date: Re: Compiler incompatibility?
- Next by Date: Re: Need help in comparing the string words in two arrays.
- Previous by thread: Re: TableSorter.java v2.1
- Next by thread: Need help in comparing the string words in two arrays.
- Index(es):