I am trying to understand how to lay out my GUI with Lemur (jME 3.1.0-stable-FINAL, lemur-1.10.1.jar). What I want is this
https://i.imgur.com/WXuDfS8.png but without doing it this way:
guiContainer = new Container();
guiContainer.addChild(new Label(longName));
SpringGridLayout gridLayout = new SpringGridLayout(Axis.X, Axis.Y);
Container settingsContainer = new Container(gridLayout);
guiContainer.addChild(settingsContainer);
int row = 0;
for (Setting setting: settings) {
TextField settingText = new TextField(Float.toString(setting.value));
Vector3f guiContainerSize = guiContainer.getPreferredSize();
Vector3f settingSize = new Vector3f(guiContainerSize.x - 30f, 20f, 0f);
settingText.setPreferredSize(settingSize); // <-- makes it 'work'
setting.setGuiTextField(settingText);
gridLayout.addChild(1, row, settingText);
Label nameText = new Label(setting.getShortName());
// nameText.setPreferredSize(new Vector3f(20f, 30f, 0f));
gridLayout.addChild(0, row, nameText);
row++;
}
The layout is a long Label on the top with below it a few rows of short Label followed by TextField. I want the short Label to always be the same width, 20 in this case. I also want the TextField to fill the remaining width, as I know my long Label at the top will make it wide enough (and if the TextField doesn’t fill it it looks rubbish). I tried setting the preferred size of the short Label without setting the TextField size but it ignored the width and only seemed to use the height https://i.imgur.com/HbaAjaE.png. I got it to ‘work’ by reading the size of the container while I’m still filling it and setting the preferred width of the TextField to that minus 20. This is horrible. So now the question: how should I set the short Label width to 20 and have the TextField fill the rest, however much that is, especially if the Container may change size?