SHARE
TWEET

PositionLayout in Scala

fedarius Aug 7th, 2011 87 Never
  1. object PositionTest extends Frame {
  2.   val button1 = new Button("Button")
  3.   val button2 = new Button("Button")
  4.  
  5.   val positionPanel = new PositionPanel {
  6.     add(button1,
  7.       Seq((PositionPanel.Property.Left, 10), (PositionPanel.Property.Right, .5f),
  8.           (PositionPanel.Property.Top, 10), (PositionPanel.Property.Bottom, 10)))
  9.    
  10.     add(button2,
  11.       Seq((PositionPanel.Property.HCenter, .125f), (PositionPanel.Property.Top, 10),
  12.           (PositionPanel.Property.Height, .25f), (PositionPanel.Property.Width, .25f)))
  13.   }
  14.  
  15.   title = "Test"
  16.   preferredSize = new Dimension(300, 200)
  17.   contents = positionPanel
  18.    
  19.   def main (args: Array[String]): Unit = {
  20.     PositionTest.visible = true
  21.    
  22.     println (PositionTest.button1)
  23.     println (PositionTest.button2)
  24.   }
  25. }
RAW Paste Data
Top