如何更改在斯卡拉ListView的内容是什么? [英] How do I change the contents of a ListView in Scala?
本文介绍了如何更改在斯卡拉ListView的内容是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图写一个小文件浏览器,我在那里显示的文件列表,并通过另一个替换列表时,我更改目录。
I'm trying to write a mini file browser, where I display a list of files, and replace the list by another when I change directories.
我可以显示一个列表:
val myList = List("Paris", "New York", "Tokyo", "Berlin", "Copenhagen")
val myListBuffer = new ListBuffer[String] ()
myListBuffer.appendAll(myList)
val myListView = new ListView(myListBuffer)
...
contents += myListView
在响应事件,我想改变显示的内容。大部分我已经试过让列表中的隐形(但向上和向下箭头仍应对选择) - 通过使他们只选择元素时,有时不可见。
In response to an event, I want to change the displayed contents. Most of what I've tried makes the list "invisible" (but still responding to selection by up and down arrows)--sometimes by making elements invisible only when they are selected!
如何更新ListView控件以反映ListBuffer的新内容?或者,可以有人点我一个这样的例子?
How do I update the ListView to reflect the new contents of the ListBuffer? Or can someone point me to an example of this?
感谢。
推荐答案
这似乎工作:
object LVTest extends SimpleSwingApplication {
def top = new MainFrame {
contents = myListView
size = new Dimension(200, 200)
}
val myListView = new ListView[String]() {
val myListBuffer = ListBuffer("Paris", "New York", "Tokyo", "Berlin", "Copenhagen")
listData = myListBuffer
listenTo(mouse.clicks)
reactions += {
case e: MouseClicked => {
myListBuffer += "Slough"
listData = myListBuffer
}
}
}
}
这篇关于如何更改在斯卡拉ListView的内容是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文