我在 Scala 中创建了一个 GUI。它非常简单,但我想从 DSLGUI 之外修改 DSLOutput 对象。有谁知道我如何从 DSLGUI 外部调用 DSLOutput.append() ?我试过导入 DSLGUI,但我似乎不知道如何访问 DSLOutput。
package api
import swing._
import event._
object DSLGUI extends SimpleSwingApplication{
def top = new MainFrame{
title = "Computer Repair Advisory System"
object Commands extends TextField(columns = 50)
object DSLOutput extends TextArea(rows = 15, columns = 50)
object SendCommand extends Button("Send")
val CommandPanel = new FlowPanel{
contents += Commands
contents += SendCommand
}
contents = new BoxPanel(Orientation.Vertical){
contents +=CommandPanel
contents += DSLOutput
}
listenTo(SendCommand)
reactions += {
case ButtonClicked(SendCommand) =>
DSLOutput append "Test "
}
}
}