Why nifty gui don't cover all screen when I start the application?

Hi.

When I start the application, Nifty GUI panels seems not to cover all JME canvas:

Then, after the first click on the canvas, nifty is readjusted.

Why can this be happening and how can I avoid it?

My interface:

[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” controller=“com.gemita.toscana.pinocchio.editor.jme.Hud”>
<layer id=“layer” childLayout=“center”>
<panel id=“panel” backgroundColor="#0fff" height=“10%” width=“100%” align=“center” valign=“bottom” childLayout=“horizontal” visibleToMouse=“true”>
<interact onClick=“defaultAction()”/>
<panel id=“panel_rotate_cw” height=“50%” width=“50%” valign=“center” childLayout=“center”>
<image filename=“Interface/img/rotate-cw.png” visibleToMouse=“true”>
<interact onClick=“startCamRotation()” onRelease=“stopCamRotation()” />

                &lt;/image&gt;
            &lt;/panel&gt;
            &lt;panel id="panel_rotate_ccw" height="50%" width="50%" valign="center" childLayout="center"&gt;
                &lt;image filename="Interface/img/rotate-ccw.png"&gt;
                    &lt;interact onClick="startCamRotation()"/&gt;
                &lt;/image&gt;
            &lt;/panel&gt;
            &lt;panel id="panel_bottom_left" height="50%" width="50%" valign="center" childLayout="center"&gt;
                &lt;text id="text" font="Interface/Fonts/Cantarell.fnt" color="#0fff" text="Hello " align="center" valign="center" /&gt;
            &lt;/panel&gt;

            &lt;!-- &lt;text id="text" font="Interface/Fonts/Cantarell.fnt" color="#0fff" text="Hello " align="center" valign="center" /&gt; --&gt;

            &lt;!-- &lt;text id="text" font="Interface/Fonts/Cantarell.fnt" color="#0fff" text="World!" align="center" valign="center" /&gt; --&gt;
            &lt;!-- &lt;control name="button" font="Interface/Fonts/Cantarell.fnt" label="Quit" id="QuitButton" align="center" valign="center"/&gt; --&gt;
        &lt;/panel&gt;
    &lt;/layer&gt;
&lt;/screen&gt;

</nifty>
[/xml]

PS- Nifty Gui buttons don’t support icon images, right? So I need to use an image as it was a button, right?

I think is a resolution issue… try to call nifty.resolutionChanged() after the window is showed or after initialization . About Buttons no nifty doesn’t support icon images but you have three choices :

  1. As you said use an image , but it’s quite unhandy since you could have some issue when you resize it.
  2. If you will intensively use of this kind of button you should create your own control class . have a look here
  3. you can modify button and add child in you xml file like this :
    [java]<control name=“button” id=“GButton0” height=“79px” width=“236px” label=“GButton0” childLayout=“center” y=“86” x=“127”>
    <image id=“GImage0” height=“39px” width=“64px” align=“left” filename=“noImage.png” x=“70”/>
    </control>
    [/java]
    This will give you a quite fast result :).

Hope this is still usefull!

bye