This mostly goes to @pspeed, but maybe somebody else has a hint as well.
Maybe Lemur refuses to handle that because it’s better handled outside of Lemur, maybe I’m just trying the wrong approach inside Lemur - any insight on the right approach appreciated.
I’m trying to create a panel with a fixed size (600 x 400 or something like that) at the center of the screen. It’s supposed to serve as the backdrop for the start-of-game GUI (configuration, game file loading/saving, that kind of stuff).
Right now, it all works, except it insists on resizing itself to fit the controls inside, instead of to 600x400. Trying to setPreferredSize just gave me an NPE in SpringGridLayout.
Here’s what I’m doing:
[java] Container backgroundPanel = new Container();
backgroundPanel.setLocalTranslation(x, screenH - y, 0);
getGuiNode().attachChild(backgroundPanel);
// this crashes because SpringGridLayout#rowPrefs is null
backgroundPanel.setPreferredSize(new Vector3f(w, h, 0));
backgroundPanel.setBackground(
new QuadBackgroundComponent(
new ColorRGBA(0.5f, 0f, 0f, 0.5f),
5f, // xMargin
5f, // yMargin
1f, // zOffset
false // lit
));
Container panel = new Container();
backgroundPanel.addChild(panel);
panel.addChild(new Label ("Blah", new ElementId("blah"), null));
[/java]
Exception stack trace:
[java]152155 [LWJGL Renderer Thread] ERROR com.jme3.app.Application - Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.NullPointerException
at com.simsilica.lemur.component.SpringGridLayout.distribute(SpringGridLayout.java:315)
at com.simsilica.lemur.component.SpringGridLayout.reshape(SpringGridLayout.java:329)
at com.simsilica.lemur.core.GuiControl.setSize(GuiControl.java:141)
at com.simsilica.lemur.core.GuiControl.revalidate(GuiControl.java:307)
at com.simsilica.lemur.core.GuiControl.controlUpdate(GuiControl.java:273)
at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:112)
at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:570)
at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:688)
at com.jme3.scene.Node.updateLogicalState(Node.java:145)
at com.jme3.scene.Node.updateLogicalState(Node.java:152)
at org.durchholz.jme3lib.ClientApplication.update(ClientApplication.java:311)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:229)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:722)
[/java]