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)
}
}
}
我怎樣才能打開新的窗口。請幫助
感謝您節省我的一天 –