gpt4 book ai didi

swing - 斯卡拉 Swing 中的树

转载 作者:行者123 更新时间:2023-12-04 11:30:55 28 4
gpt4 key购买 nike

我想在我的 Scala 摆动应用程序中使用一棵树,但该组件在 API 中不可用。

是否包装了 JTree存在吗?

如果没有,你对制作有什么建议吗?

谢谢

最佳答案

即使您可以在 Scala 程序中直接使用 Java JTree,如 this thread 所示。 ,存在关于包含 JTree 的 Scala 包装器的争论。

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.



design is in progress , 和 JTree wrapper proposal is available in this GitHub repo , 制作人 kenbot (Ken Scambler) .

关于swing - 斯卡拉 Swing 中的树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4049628/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com