Problem with a PanelBuilder since i updated my version of JME

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() {
                    text(new TextBuilder() {
                    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:

at de.lessvoid.nifty.Nifty.createElementFromTypeInternal(
at de.lessvoid.nifty.Nifty.createElementFromType(
at Maquisard.GuiControl.buildConfigurationMenu(

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,


Hmm, I looked at our code and we also just construct Nifty panels like this. Usually we give the ID as parameter but not always. And it does work, although we are using jME 3.5.1. Nifty changes are rare though after jME 3.3. Should be almost non-existent.

I vaguely remember something when I upgraded to 3.3 for my game, but its been years since then so I don’t remember exactly what it was. If you look at the nifty source code, the method that errors out has a signature of:

private Element createElementFromTypeInternal(
      @Nonnull final Screen screen, @Nonnull final Element parent,
      @Nonnull final ElementType type,
      @Nonnull final LayoutPart layoutPart,
      final int index)

So it implies that one of those elements is null in your example. You could set a breakpoint there and check. My guess off-hand would be that the text builder isn’t setting a default layout and when you remove everything from the panel then the panel doesn’t have a layout so it causes an error.

1 Like


Finally i fixed my problem after lots of try of various thing, and i’ve come to the following conclusion: the “build” method now only works if the screen and container is currently displayed and active. This was not the case before. That code was running at beginning of application, i’ve moved it to execute when user load the configuration screen for the first time.

Thanks for trying to help