How to add more than one component to MainFrame contents

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.

-------------Problems Reply------------

MainFrame, as you have discovered, can contain only one thing.

Therefore, you need to place both parameters and controls into some container that is designed to lay out multiple other containers. You already used a FlowPanel for this--you could do so again. Alternatively, a BoxPanel in direction Orientation.Vertical is probably more what you had in mind.

So you add the other containers to that BoxPanel, and then set the BoxPanel as MainFrame's contents.

Category:swing Views:1 Time:2011-05-13
Tags: swing scala

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.149 (s). 11 q(s)