I’m running Lemur 1.9.1 on jME 3.1.0-beta3. I’m designing a login screen for my game, which at the moment consists of only two text fields (username & password) and a “Login” button attached to a background panel. I’ve tried using several different layouts, but none of them gave a result that was anything near what I wanted. Consequently I decided to drop the layouts in favor of directly attaching textfields and button as children of the background panel node, which from reading several forum topics on layout seems to be the way to get absolute positioning. Doing it this way, however, results in components without any borders/background:
So i start with a primary container. If i want two or more columns i add a container as a child and set the row/columns in that container. This way i can have as many columns as i want wherever i want.
The user name and password section is one container with a SpringGridLayout… ie: the default setup.
The button panel at the bottom is another container. Then they all go in the outer container.
Container window = new Container();
Container form = window.addChild(new Container();
form.addChild(new Label("User name:")); // starts a new row because no row/col specified
form.addChild(new TextField("Textfield"), 1); // column specified, continues current row
form.addChild(new Label("Password:")); // starts a new row because no row/col specified
form.addChild(new PasswordField(""), 1);// column specified, continues current row
window.addChild(new Checkbox("Checkbox (Remember Password)"));
// Create a button panel in column major layout
Container buttons = window.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y)));
buttons.addChild(new Button("Another Button"));
…and then if you want the window bigger, set it’s preferred size large and everything will stretch.
But probably what you want is to set the insets of the form and buttons containers.
The whole thing would need some significant re-aligning if I leave it like that, but it does look nicer with the labels right next to the text fields. I think I’ll try squishing it down significantly in both height/width to reduce whitespace.
(Marking this topic as solved since my original problem is taken care of, but as long as you’re happy to keep giving UI design advice, I’m happy to keep getting it.)
Yeah, personally, usually I start with little to no insets and then add them where I think the UI would be clearer if things were separated a bit. Even sometimes putting the borders back can help break things up.
Note: if you ever want your form (label/value) style things to not have so much whitespace on the left then you can also mess with the FillMode of the layout.
new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, FillMode.Last))
…is usually what I use for form style layouts.
It leaves it in row-major mode, makes it so components in the layout are never resized vertically by the layout stretching, but only the last column’s components will be resized horizontally by stretching the layout.
It’s nicer for having wide edit fields without having to have a huge window to hold them.