Home

FlowPanel

FlowPanel

A scala.swing.FlowPanel lays out its components from left to right, with some separating space in between:

FlowPanel

It's not possible to control the spacing with glue (but struts work). Different from a BoxPanel(Orientation.Horizontal), the elements are spread over multiple lines if the window is not wide enough:

FlowPanel when window is not wide enough

Here is the code for this example:
import scala.swing._

class UI extends MainFrame {
  title = "Flow Panel"
  contents = new FlowPanel {
    contents += new Label("A Label")
    contents += Swing.HStrut(30)
    contents += new Button("A Button")
    contents += new Button("Another Button")
    contents += Button("Close") { sys.exit(0) }
  }
}

object PanelOne {
  def main(args: Array[String]) {
    val ui = new UI
    ui.visible = true
  }
}