class PositionPanel extends Panel with LayoutContainer {
import PositionPanel._
type Constraints = Seq[Tuple2[Property.PropertyValue, _ >: Double with Float with Int]]
def layoutManager = peer.getLayout.asInstanceOf[PositionLayout]
override lazy val peer = new javax.swing.JPanel(new PositionLayout) with SuperMixin
def areValid(c: Constraints): (Boolean, String) = (true, "")
def constraintsFor (comp: Component) = {
var cs = layoutManager.getConstraints (comp.peer)
var seq: Constraints = Nil
cs foreach {
c => seq = seq :+ (c.property, c.value)
}
seq
}
def add(c: Component, l: Constraints) {
layoutManager.addLayoutComponent (c.peer, convertConstraints (convertConstraints (l)))
}
}
object Test extends SimpleSwingApplication {
val button1 = new Flex4Button
def top = new MainFrame {
title = "Test"
preferredSize = new Dimension(860, 400)
contents = new FlowPanel {
background = Color.RED
contents += button1
}
}
def main: Unit = main(Array())
}
object PositionTest extends SimpleSwingApplication {
val button2 = new Button("Button")
val positionPanel = new PositionPanel {
preferredSize = new Dimension(200, 200)
background = Color.BLUE
add(
button2,
Seq((PositionPanel.Property.Left, 10), (PositionPanel.Property.Right, 10)))
}
def top = new MainFrame {
title = "Test"
preferredSize = new Dimension(860, 400)
contents = new FlowPanel {
contents += positionPanel
}
positionPanel.revalidate
println (this)
println (contents(0))
println (positionPanel)
}
def main: Unit = main(Array())
}