斯卡拉秋千上的树 [英] Tree in scala swing

查看:91
本文介绍了斯卡拉秋千上的树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Scala swing应用程序中使用树,但是该组件在API中不可用.

I want to use a tree in my Scala swing application, but the component isn't available in the API.

JTree的包装是否存在?

如果没有,您对此有何建议?

If not, do you have any advice for making it ?

谢谢

推荐答案

即使您可以在scala程序中直接使用Java JTree,如

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.

以下常见用法繁琐,冗长,非类型安全和/或要求使用不安全的null用法:

The following common usages are tedious, verbose, non-type safe, and/or require unsafe null usage:

  • 创建一个由您自己的用户对象支持的自定义树模型-Scala 摆动的方法是在其后面有一个标准的typesafe Map
  • 事件-由树创建的事件堆-TreeWillExpandListenersTreeSelection等-使用Reactor/Publisher PartialFunction模型将使此代码更具可读性和简洁性.
  • 可编辑组件-这是通过scala.swing中其他位置的隐式值完成的,并且也应该在此处.
  • 自定义渲染器-不记得Scala如何处理这些渲染器,但这在Java Swing中也总是很奇怪.
  • 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.

最重要的是,JTrees是在Java中使用时的巨大痛苦,这并不是没有特别好的理由.对于Scala Swing用户而言,Scala包装器将是一大福音.

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.

设计已在进度,并且 JTree包装器建议可在此GitHub存储库中使用 >,由 kenbot(Ken Scambler)制作.

这篇关于斯卡拉秋千上的树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆