Nifty gui windows

Hi,

I’m trying to organize my HUD in nifty gui windows that the user can place freely anywere on the screen. I plan to make them closeable and make the user able to open them again by clicking items on the hotbar (which is also a window, but isn’t closeable)

I have already added some of the windows and the hotbar in the HUD screen, but I’ve hit two problems:

First problem: I want to be able to change the hotbar between a horizontal and a vertical layout, but the icons in the vertical versions are placed next to the window, instead of behind it. Here is a screenshot of the problem:

This is the xml code I used to define the hotbar window:
[java]
<control name=“window” id=“hotbar” title=“Hotbar” width=“300px” height=“54px” closeable=“false”>
<panel childLayout=“horizontal” id=“hotbarC”>
<image filename=“Interface/GUI/Hotbar_icoon_layout.png” id=“Ilayout”>
<interact onClick=“hotbarAction(0)” />
</image>
<panel width=“5px” height=“5px” />
<image filename=“Interface/GUI/Hotbar_icoon_chat.png” id=“Ichat” />
<panel width=“5px” height=“5px” />
<image filename=“Interface/GUI/Hotbar_icoon_rugzak2.png” id=“Irugzak” />
<panel width=“5px” height=“5px” />
<image filename=“Interface/GUI/Hotbar_icoon_quests.png” id=“Iquests” />
<panel width=“5px” height=“5px” />
<image filename=“Interface/GUI/Hotbar_icoon_teleporters.png” id=“Iteleporters” />

                &lt;panel width="5px" height="5px" /&gt;
                &lt;image filename="Interface/GUI/Hotbar_icoon_rugzak2.png" id="Irugzak" /&gt;
                &lt;panel width="5px" height="5px" /&gt;
                &lt;image filename="Interface/GUI/Hotbar_icoon_quests.png" id="Iquests" /&gt;
                &lt;panel width="5px" height="5px" /&gt;
                &lt;image filename="Interface/GUI/Hotbar_icoon_teleporters.png" id="Iteleporters" /&gt;
                
            &lt;/panel&gt;
        &lt;/control&gt;

[/java]
And here’s the java code I use to switch between layouts:
[java]
public void hotbarAction(String action){
int i = Integer.parseInt(action);
switch(i){
case 0:
//Change layout of hotbar
WindowControl hotbar = nifty.getCurrentScreen().findControl(“hotbar”, WindowControl.class);
Element e = nifty.getCurrentScreen().findElementByName(“hotbarC”);
if(hotbar.getHeight() == 54){
hotbar.setWidth(new SizeValue(“34px”));
hotbar.setHeight(new SizeValue(“300px”));
e.setWidth(32);
e.setHeight(300);
e.setLayoutManager(new VerticalLayout());
hotbar.layoutCallback();
hotbar.dragStart(0, 0); //This causes the window to update. Witouth this function call, the window won’t change untill it’s clicked.
} else {
hotbar.setWidth(new SizeValue(“300px”));
hotbar.setHeight(new SizeValue(“54px”));
e.setWidth(300);
e.setHeight(32);
e.setLayoutManager(new HorizontalLayout());
hotbar.dragStart(0, 0);
}
break;
}
}
[/java]
What am I doing wrong here?

Secound problem: How can I re-open windows that the user closed? And how can I detect if windows are closed? (The inventory needs to know this, since the window is nifty-gui based, but it’s items are objects in the guiNode)

Many thanks in advance.