ObservableBuffer 发布 Swing 事件
如何让 scala.collection.mutable.ObservableBuffer 发布 swing 事件,以便在缓冲区更改时更新我的组件?
令人困惑的是,scala 有两个 Publisher 实现。第一个是 scala.collection.mutable.Publisher,第二个是 scala.swing.Publisher。不幸的是,ObservableBuffer
仅扩展了 Publisher
第一种类型。
How do I make a scala.collection.mutable.ObservableBuffer
publish swing events so that I can update my components when a buffer changes?
The confusing thing is that scala has two implementations of Publisher
. One is scala.collection.mutable.Publisher
and the second is scala.swing.Publisher
. It's unfortunate that ObservableBuffer
only extends the first type of Publisher
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以编写一个 ObservableBuffer 的子类,将事件从 Scala 方式转换为 Swing 方式。我这样做是为了将
ObservableBuffer
转换为 EclipseIObservableList
,您可以在这里查看:https://gist.github.com/951288请注意,这是一个快速复制粘贴,并非所有内容都可以编译,但您明白了。
You can write a subclass of
ObservableBuffer
that translates the events from the Scala way to the Swing way. I did that to turn anObservableBuffer
into a EclipseIObservableList
, you can check it out here: https://gist.github.com/951288Note that it is a fast copy-paste, not everything may compile, but you get the idea.