[solved] Nifty - no display of controls

Hello, I try to use the Nifty library. I create an xml file with the screen and the panel that appears correctly in the game. But when I add a “control” tag with a name Button or name Textfield type, etc. nothing appears in the game.
As if this beacon was not interpreted.
Only the correct panel is displayed on the screen

file Xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nifty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
    <screen id="start" controller="appState.GuiAppState">
        <layer id="GLayer0" childLayout="center" controller="appState.GuiAppState">
            <panel id="GPanel1" childLayout="center" backgroundColor="#ff5000" width="50%" style="nifty-panel-simple" height="30%">
                <control name="button" id="GButton0" childLayout="center" backgroundColor="#aa11ff" width="157px" x="-1px" y="-1px" label="GButton0" height="27px"/>

Here is the initialization code:

public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
     NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(
    app.getAssetManager(), app.getInputManager(), app.getAudioRenderer(), app.getGuiViewPort());
    Nifty nifty = niftyDisplay.getNifty();
    nifty.fromXml("Interface/IUBase.xml", "start");



By reading the documentation, I do not see what I’m doing wrong.

Do I forget anything?

Thank you for your help


PS : I use Jmonkey SDK 3.2 prealpha

when I look at the console, I notice a warning:

WARNING: controlDefinition [button] missing.

When I create a controlDefinition file and associate it with the file, it shows me a semblance of a button.

<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls xmlns="http://nifty-gui.lessvoid.com/nifty-gui">
    <controlDefinition style="your-style" name="button">
        <panel style="#panel" >

I get the impression that it does not recognize the controlDefinition (button). The latter should be implemented in the library.

Am I wrong ?

Am I wrong ?

You are missing the default controls and default styles. The wiki should have shown that.

<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />

Thank you, it works.

The worst thing is that I read it yesterday by browsing the wiki in the controls additions.

A big thank-you


1 Like

You are very welcome :slight_smile: