Jtree complete replacement...

OK, I’ve finally got so frickin hacked-off with Jtree that I think I might try writing my own one. From scratch. Without all the sh*t in JTree, but WITH all the basic functionality that any tree would need (much of which JTree lacks).

Obviously, I fear this may be a long and difficult task - perhaps JT is so terrible because it’s actually really hard to implement a good tree?

I’ve seen two JTree replacements for java during the last 5 years, but both of them were commercial (ouch; this is a basic library item, and you get charged for it?).

Has anyone seen a replacement (nb: if it extends JTree it’s probably a complete waste of time - needs to be a from-scratch rewrite) that is free before I start on this? :).

Or has anyone tried the commercial ones? If they’ve still got problems, perhaps I could offer a very very cheap commercial license ( $5 or less ) as well as a “cut-down” free version - that might let me keep a well-maintained, decent, free (as in beer) JTree replacement whilst not going hungry.

Go on Adam, spill the beans. What’s got your goat about the JTree?

Cas :slight_smile:

[quote]Go on Adam, spill the beans. What’s got your goat about the JTree?

Cas :slight_smile:
[/quote]
I smell troll in the air, but…

In short, the API is a dog’s dinner. Since it doesn’t even integrate nicely with the other Swing components (JTable, JList, etc) the only good thing most people can say about it is that it works (but c.f. below).

My particular problems include:
[list]
[] TreePath should not exist, it should be an interface if it has to.
[
] TP has the appearance of a 1st year compsci student writing “my first tree data structure”. It’s crap.
[] JT has major multiple-personality disorder: some methods are TP-only, others are “visible row out of those on the screen” only, others are both.
[
] Visible row on screen is ill-defined, and incompletely accessible (from trial and error it appears it’s particularly difficult to work in visible-rows because you don’t know what’s first, you don’t know the set of indices that are currently visible, etc - the methods for ascertaining this simply don’t exist)
[] There are approx 125 new methods in Jtree; that’s about 4 times as many as are absolutely necessary IMHO - it also suggests that the API is likely to be evil to try and use (which it is :))
[
] TreeNode. Well, rather like TP it’s a stupid class (with simlar problems) and it CERTAINLY should not be in the JTree class - this is the kind of thing that should only ever be in a subclass or similar.
[] TreeModel is a crap i/f to model trees; again, it appears to have been designed by someone so thoroughly inexperienced with GUI dev that they had no idea what the appropriate methods were for such a major interface. At least they made it an interface, so I should be grateful, I guess.
[
] TM allows null roots, even though JT falls into a wet heap with all sorts of subtly weird behaviour whenever you do this
[] JT’s friends have a pathological desire to collapse nodes whenever possible; to correct this, you have to subclass loads of methods (the collapsing is spread around quite liberally).
[
] It’s just massively unwieldy and gives people a serious headache trying to work with it. There’s plenty more to complain about other dependent classes (like the TreeModelEvent’s etc), but I’ll stick with just covering the tightly integrated ones.

OTOH, it does work - albeit almost never the way you want it too, and with considerable pain on the dev’s behalf.

It’s also got some decent performance enhancing stuff inside.

PS FYI it seems the standard price to license 3rd party Jtree impls is $200-400 !!! (single license, single dev, single product; site licenses and multi-product are more). It seems we’re all in the wrong business…

Well… just to represent another point. I’ve never really had a problem with it. I can only recall wanting one extra method or method change… something to do with an API that took an array of TreeNodes instead of a TreePath or vice-versa.