I think the BoxLayouts aren’t working like you want. Just leave them out and let the default SpringGridLayout work for you.
With your current approach, you will also have the problem that your columns won’t line up.
Make one container and add the Options label and another container to it…
Container window = new Container();
Container form = window.addChild(new Container());
// Then for each row you in the "form":
form.addChild(new Label("My Label")); // automatically adds a new row
myTextField = form.addChild(new TextField(""), 1); // the ending 1 will put it in the second column of the current row
You could also do it all explicitly stating each row and column but that’s a pain.
You can see any of a half-dozen examples of this in various pieces of my open source code.
If you search around in these projects you are bound to find hundreds of examples:
Thank you. Your idea is nice, it is used in Examples/MainMenuState.java at master · Simsilica/Examples · GitHub (in initialize() routine, declaring connection port and host interface elements). But when I declare an empty textfield (without any preset text), it does not display on screen. Here is the code:
optWindow.setLocalTranslation(leftLocationOptWindow, topLocationOptWindow, 0);
optWindow.addChild(new Label("Options"));
com.simsilica.lemur.Label fieldDim1Label = new com.simsilica.lemur.Label("Field Dim 1");
fieldDim1Text = new com.simsilica.lemur.TextField("");
optWindow.addChild(fieldDim1Label);
optWindow.addChild(fieldDim1Text, 1);
//not working (no onscreen change)
fieldDim1Text.setSize(new Vector3f(30f, fieldDim1Text.getSize().y, fieldDim1Text.getSize().z));
com.simsilica.lemur.Label fieldDim2Label = new com.simsilica.lemur.Label("Field Dim 2");
fieldDim2Text = new com.simsilica.lemur.TextField("");
optWindow.addChild(fieldDim2Label);
optWindow.addChild(fieldDim2Text,1);
//not working
fieldDim2Text.setSize(new Vector3f(30f, fieldDim2Text.getSize().y, fieldDim2Text.getSize().z));
Yes… because the preferred size for an empty text field is 0 width. You can set the preferred width or the preferred size and then it will adjust accordingly. See the javadocs.
The javadoc has the methods but not a description. I just meant that you could find the actual method name and figure out how to call it from the javadoc.
Glad you fixed your issue… and I think your newer approach looks better, too.