1

I want to know how to navigate between panels in scala swinng. the current code I have is:

 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"     
    }

I want the buttonStart button to take me to another frame that I define in another class. How exactly do I implement that in scala. I get a recursive value error from what I have above.

Matthew Kemnetz
  • 845
  • 1
  • 15
  • 28

1 Answers1

1

Do you want to start a new window, or just switch the contents of the current window? If it's the latter, CardLayout is what you're looking for.

Which line in your example causes the error? I suspect it's the top.visible = false. This would be because the compiler needs to know the type of top but can't infer it because you have a reference to it in its definition. Adding a type annotation should fix this error:

val top: MainFrame = new MainFrame {
Luigi Plinge
  • 50,650
  • 20
  • 113
  • 180