0

I am using Swing in Scala "org.scala-lang" % "scala-swing" % "2.11.0-M7". I want to set position for my components explicitly. It is possible to do in Swing API for Java.

Question: is it possible to set absolute position for components in Swing Scala API?

Swing API for Scala example:

import scala.swing._
object PositionAbsolute extends SimpleSwingApplication {
  lazy val top = new MainFrame() {
    title = "PositionAbsolute"
    val label = new Label("I want to be at (0, 0)")
    val panel = new FlowPanel()
    panel.preferredSize = new swing.Dimension(300, 400)
    panel.contents += label
    contents = panel
  }
} 

How it renders

kisileno
  • 777
  • 8
  • 23
  • 2
    *"I want to set position for my components explicitly. It is possible to do in Swing API for Java."* Being 'possible' does not make it a 'good idea'. Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and borders for [white space](http://stackoverflow.com/a/17874718/418556). – Andrew Thompson May 24 '16 at 01:39
  • Is this a [XY-Problem?](http://xyproblem.info/) Why do you want to position your components absolutely? – hamena314 May 24 '16 at 08:13

0 Answers0