I want to make window with few panels. I can append one to MainFrame’s contents:
import swing._
class View(model:Model) extends MainFrame {
title = "app"
val parameters = new FlowPanel() {
contents += new Label("Tempo: ")
contents += new ComboBox(Seq("80", "100", "120", "140"))
contents += new Label("Metric: ")
contents += new Label("Note: ")
}
contents = parameters
}
but when I try to append another:
class View(model:Model) extends MainFrame {
title = "app"
val parameters = new FlowPanel() {
contents += new Label("Tempo: ")
contents += new ComboBox(Seq("80", "100", "120", "140"))
contents += new Label("Metric: ")
contents += new Label("Note: ")
}
val controls = new FlowPanel() {
contents += new Button( "klop" )
}
contents = parameters
contents += controls
}
it doesn’t works:
src/View.scala:40: error: type mismatch;
found : scala.swing.FlowPanel
required: String
contents += controls
^
one error found
Error: Build failed.
How should I do that? I tried with a Container but I don’t know how to use it properly.
MainFrame, as you have discovered, can contain only one thing.Therefore, you need to place both
parametersandcontrolsinto some container that is designed to lay out multiple other containers. You already used aFlowPanelfor this–you could do so again. Alternatively, aBoxPanelin directionOrientation.Verticalis probably more what you had in mind.So you add the other containers to that
BoxPanel, and then set theBoxPanelasMainFrame‘s contents.