0
我正在scala中创建一个应用程序。我想打开一个按钮点击框架。我是斯卡拉新手。下面是代码scala打开框架上的按钮点击
import scala.swing._;
import java.io._;
import scala.swing.event._;
import javax.swing.ImageIcon;
object Try1 extends SimpleSwingApplication {
def top = new MainFrame {
title = "First Swing App";
val button = new Button {
text = "Proceed"
}
contents = new BoxPanel(Orientation.Vertical) {
contents += button
border = Swing.EmptyBorder(30, 30, 30, 30)
}
val obj = new Try2();
listenTo(button)
reactions += {
case ButtonClicked(button) =>
//here 2nd frame must be open
}
}
对于要打开的窗口中的代码是这样的
import javax.swing.ImageIcon
import scala.swing._
class Try2 extends SimpleSwingApplication {
def top = new MainFrame {
title = "Second Swing App";
val button = new Button {
text = "Proceed"
}
contents = new BoxPanel(Orientation.Vertical) {
contents += button
border = Swing.EmptyBorder(30, 30, 30, 30)
}
}
}
我怎样才能打开新的窗口。请帮助
感谢您节省我的一天 –