I want to use a tree in my Scala swing application, but the component isn't available in the API.
Does a wrapper of JTree
exists ?
If not, do you have any advice for making it ?
Thanks
I want to use a tree in my Scala swing application, but the component isn't available in the API.
Does a wrapper of JTree
exists ?
If not, do you have any advice for making it ?
Thanks
Even though you can use directly the Java JTree in your scala program, as illustrated by this thread, there is a debate about including a Scala wrapper of a JTree.
The following common usages are tedious, verbose, non-type safe, and/or require unsafe null usage:
- Creating a custom tree model, backed by your own user objects -- the Scala Swing way would be to have a standard typesafe
Map
behind it- Events - there are heaps of events created by trees --
TreeWillExpandListeners
,TreeSelection
, etc -- Using the Reactor/PublisherPartialFunction
model would make this code far more readable and concise.- Editable components -- This is done with implicit values elsewhere in scala.swing, and should be here too.
- Custom renderers -- Can't remember how Scala deals with these, but this is always fiddly in Java Swing too.
Bottom line is,
JTrees
are a massive pain to use in Java, for no particularly good reason. A Scala wrapper would be a massive boon for Scala Swing users.
A design is in progress, and a JTree wrapper proposal is available in this GitHub repo, made by kenbot (Ken Scambler).