开发者

Tree in scala swing

I want to use a tree in my Scala swing开发者_Python百科 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/Publisher PartialFunction 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜