2011-12-15 85 views
1

我想知道如何在scala swinng中的面板之间导航。我现在的代码是:在scala中的面板之间导航

val top = new MainFrame { 

    title = "Predator and Prey Agent simulation"  
    val buttonExit = new Button { 
    text = "Exit" 
    //foo 
} 

    val buttonStart = new Button {  
     top.visible = false 
     text = "Play"  
    } 

我想buttonStart按钮带我到另一个框架,我在另一个类中定义。我到底该如何在scala中实现它。我从上面得到了一个递归值错误。

回答

1

你想开始一个新的窗口,或只是切换当前窗口的内容?如果是后者,CardLayout就是你要找的。

您示例中的哪一行导致错误?我怀疑这是​​。这是因为编译器需要知道top的类型,但不能推断它,因为您在其定义中引用了它。添加类型注释应该修复此错误:

val top: MainFrame = new MainFrame {