I’m trying to use scala.swing package for my gui’s. Before that, I was using plain GroupLayout (was writing it by hand :), but scala way seems better. I ran into some problems though – I like BoxLayout, but when I try to add several panes into it, and try to specify different horisontal alignments, I get something strange.
Here is the code:
new Frame {
contents = new BoxPanel(Orientation.Vertical) {
contents += new Button("A") {
xLayoutAlignment = 1.0f
}
contents += new Button("B")
size = (200, 200)
}
size = (200, 200)
visible = true
peer.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
}
At the very least, I expected to see button B to the left of the button A. Here is what I saw:

Java version of this code does exactly the same, so it is not scala.swing bug.
What am I doing wrong?
It’s the way BoxLayout was designed to work.
See Fixing Alignment Problems for a better explanation and a simple demo that allows you to play with alignments to better understand how they work.