How do I get the child component for a particular position on a Scala Swing BorderPanel? I can place components OK. In this particular case I want to check the component at BorderPanel.Position.Centre. Also am I right that there can only be one child component or a null at each position: North, East etc?
Well, the layout
is a Map from component to position, so the following works (not sure if there's an easier way):
import scala.swing.SimpleSwingApplication
import scala.swing.MainFrame
import scala.swing.BorderPanel
import scala.swing.Label
object BorderLayoutTest extends SimpleSwingApplication {
def top = new MainFrame {
contents = new BorderPanel {
val label = new Label("hi")
import BorderPanel.Position._
layout(label) = Center
println("North: " + layout.find(_._2 == North)) //None
println("Center: "+ layout.find(_._2 == Center)) //Some( ... )
}
}
}