Image not working [SOLVED]

I feel like an idiot having to post about this problem but this is my first time using nifty and I can’t figure out what’s wrong. I’m following the layout tutorial (https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_xml_layout) and I’m at the ‘Add Imagines’ part. Instead of using the backbround image I put in the filepath for my own image, also a png. When I check the gui it’s all just dark gray. When I remove the image line the normal colorful panels show up as in the image just above. What am I doing wrong?

Your code looks fine from what I can see. :wink:



Though, it might help if we could see it. :slight_smile:



Edit: or at least the XML in this case.

Touche sir. Sorry wasn’t thinking.

Also, I tried adding the code for the buttons now too and they aren’t showing up either.



[xml]

<?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”>

<layer id=“background” backgroundColor="#ffff">

<image filename=“Interface/Untitled-1.png”></image>

</layer>

<layer id=“foreground” backgroundColor="#0000" childLayout=“vertical”>

<panel id=“panel_top” height=“25%” width=“75%”

align=“center” childLayout=“center” backgroundColor="#f008">

<text text=“My Cool Game” font=“Interface/Fonts/Default.fnt” width=“100%” height=“100%” />

</panel>

<panel id=“panel_mid” height=“50%” width=“75%”

align=“center” childLayout=“center” backgroundColor="#0f08">

<text text=“Here goes some text describing the game.”

font=“Interface/Fonts/Default.fnt” width=“100%” height=“100%” wrap=“true” />

</panel>

<panel id=“panel_bottom” height=“25%” width=“75%”

align=“center” childLayout=“horizontal” backgroundColor="#00f8">

<panel id=“panel_bottom_left” height=“50%” width=“50%”

valign=“center” childLayout=“center” backgroundColor="#44f8">

<control name=“button” label=“Next” id=“NextButton” align=“center” valign=“center”>



</control>

</panel>

<panel id=“panel_bottom_right” height=“50%” width=“50%”

valign=“center” childLayout=“center” backgroundColor="#88f8">

<control name=“button” label=“Quit” id=“QuitButton” align=“center” valign=“center”>



</control>

</panel>

</panel>

</layer>

</screen>



</nifty>

[/xml]

Others will have to help in this case. I’ve never used the image tag. I just looked and all of my screens use backgroundImage for everything.



But at least now they can see what you have. :slight_smile:

Running your example using the SDK I get this Exception:



[java]java.lang.RuntimeException: missing childLayout attribute for an element with [1] child elements. Attributes of error element [backgroundColor => #ffff, id => background]

at de.lessvoid.nifty.loaderv2.types.ElementType.enforceChildLayout(ElementType.java:187)

at de.lessvoid.nifty.loaderv2.types.ElementType.applyStandard(ElementType.java:176)

at de.lessvoid.nifty.loaderv2.types.ElementType.create(ElementType.java:144)[/java]



The cause is the line:



[xml]<layer id="background" backgroundColor="#ffff">[/xml]



which is missing a childLayout attribute which is required by Nifty to know how it should layout the image in that layer. Changing the line like so:



[xml]<layer id="background" backgroundColor="#ffff" childLayout="vertical">[/xml]



works for me and I can see the image.

Allrighty that fixed it. Thank you. And would you look at that, it was giving me that RuntimeException all along as well but I never thought to look there for the cause since the actual program never crashed. Must have been really tired last night >.<