Hello everyone,
I updated recently my version of JME to the last one (v3.3.0), and it caused an issue in my Nifty GUI code: I use some PanelBuilder at two locations, and in one of them, it returns Null without any more explaination. I don’t understand what changed in the last version to cause that.
Here is the code where it returns Null:
public void buildConfigurationMenu() {
final KeyboardConfiguration configuration = KeyboardConfiguration.getInstance();
Screen configuration_screen = nifty.getScreen("configuration");
Element configuration_container = configuration_screen.findElementByName("key_list");
for (int i = 0; i < configuration.featureCount(); i++) {
final String featureName = configuration.featureName(i);
final ArrayList<Integer> keys = configuration.featureKeys(i);
final int index = i;
new PanelBuilder() {
{
childLayoutHorizontal();
text(new TextBuilder() {
{
text(featureName);
font("Interface/Fonts/Default.fnt");
backgroundColor("#0008");
width("200px");
height("30px");
wrap(true);
}
});
control(new ButtonBuilder("KeyButton" + index, KeyboardConfiguration.keyName(keys.get(0))) {
{
id("KeyButton" + index);
interactOnClick("assignKey(" + index + ")");
}
});
control(new ButtonBuilder("ResetKeyButton" + index, "Reset") {
{
id("ResetKeyButton" + index);
interactOnClick("resetKey(" + index + ")");
}
});
}
}.build(nifty, configuration_screen, configuration_container);
}
}
It’s the line with “build” at the end which cause the following error:
java.lang.NullPointerException
at de.lessvoid.nifty.Nifty.createElementFromTypeInternal(Nifty.java:1834)
at de.lessvoid.nifty.Nifty.createElementFromType(Nifty.java:1820)
at de.lessvoid.nifty.builder.ElementBuilder.build(ElementBuilder.java:638)
at de.lessvoid.nifty.builder.ElementBuilder.build(ElementBuilder.java:684)
at Maquisard.GuiControl.buildConfigurationMenu(GuiControl.java:302)
I tried to remove content inside the panelBuilder, but even an empty one still returns null. I also tried to call that function later than i used too (it’s called just once, normally after the GUI is set up), nut nothing change.
Does anyone already experienced similar problem ?
Thanks in advance,
Gael