Why <Text> objects don't appear in my xml gui when they run


I am trying to learn how to use NIFTY GUI, and the is a problem with the xml.

here is the code of XML file:

<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
    <!-- +++++++++++++++++++++++++++++++++++++++ -->
    <!-- start screen -->
    <!-- +++++++++++++++++++++++++++++++++++++++ -->
    <screen id="start" controller="mygame.Main">
        <layer id="layer" backgroundColor="#003f" childLayout="center">
            <panel id="panel" height="25%" width="35%" align="center" valign="center" backgroundColor="#f60f" childLayout="center" visibleToMouse="true">
                <interact onClick="quit()"/>
                    <onStartScreen name="move" mode="in" direction="top" length="300" startDelay="0" inherit="true"/>
                    <onEndScreen name="move" mode="out" direction="bottom" length="300" startDelay="0" inherit="true"/>
                    <onHover name="pulsate" scaleFactor="0.008" startColor="#f600" endColor="#ffff" post="true"/>
                <text id="text" color="#000f" text="Hello World!" align="center" valign="center" />

And here is the code o TestNiftytoMesh.java file I am using to learn nifty gui:

package mygame.Examples;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.Camera;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture.MagFilter;
import com.jme3.texture.Texture.MinFilter;
import com.jme3.texture.Texture2D;
import de.lessvoid.nifty.Nifty;

public class TestNiftyToMesh extends SimpleApplication{

    private Nifty nifty;

    public static void main(String[] args){
        TestNiftyToMesh app = new TestNiftyToMesh();

    public void simpleInitApp() {
       ViewPort niftyView = renderManager.createPreView("NiftyView", new Camera(1024, 768));
       niftyView.setClearFlags(true, true, true);
        NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
        nifty = niftyDisplay.getNifty();
        nifty.fromXml("Interface/MainMenuGui.xml", "start");

        Texture2D depthTex = new Texture2D(1024, 768, Format.Depth);
        FrameBuffer fb = new FrameBuffer(1024, 768, 1);

        Texture2D tex = new Texture2D(1024, 768, Format.RGBA8);

        niftyView.setClearFlags(true, true, true);

        Box b = new Box(Vector3f.ZERO, 1, 1, 1);
        Geometry geom = new Geometry("Box", b);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setTexture("ColorMap", tex);

If you run this code, you will see the background and panel colors, but the one thing you will not see is TEXT.

Why is that, I want to know why and be able to fix it.

Any ideas.


I don’t get to see the Hello World!, all I see is the background and panel colors.

Update: I noticed that when I try to use the font attribute, it tells me font does not exist. (Do I need to have font uploaded to my interface folder?) So I removed the attribute, but now I don’t see the Hello World! text.