[SOLVED] Problem with creating dynamic windows

I am trying to create dynamic window to display some info messages.

[java]

public void showInfoWindow(final String title, final String text)

{

final String windowId = “_infoWindow” + nextWindowId++;



new LayerBuilder("_infoWindowLayer"){{

childLayoutAbsolute();

width(“100%”);

height(“100%”);

control(new WindowBuilder(windowId, title) {{

visibleToMouse(true);

closeable(false);

width(“50%”); // windows will need a size

height(“150px”);

x(“25%”);

y(“35%”);

panel(new PanelBuilder("_rootPanel") {{

height(“100%”);

width(“100%”);

alignCenter();

childLayoutVertical();

color("#00000000");

control(new LabelBuilder("_infoText") {{

text(text);

style(“base-font”);

color("#eeef");

valignCenter();

width(“100%”);

height(“75%”);

}});

control(new ButtonBuilder("_btnOk") {{

name(“button”);

label(“OK”);

alignCenter();

width(“50%”);

height(“25%”);

interactOnClick(“closeInfoWindow(” + windowId + “)”);

}});

}});

}});

}}.build(nifty, screen, screen.getRootElement());



}

[/java]



But the problem is that I don’t see window but just a text content at the top left corner. If I call this method from bind() all work. Also if I switch to another screen and then back window is displayed. If I call this method twice I see new window and if I try move it the first is jumped to the center of the screen and also works.

calling [java]screen.layoutLayers()[/java] is necessary after calling build() in this case. This is happening automatically in bind() or when you call gotoScreen() which explains why it works in some cases.



The builder API is kinda awkward in that respect since I agree that this should happen automatically in this case :frowning:

2 Likes

Thanks a lot. It helped me. How can I mark topic as resolved?

1 Like
@lamao said:
Thanks a lot. It helped me. How can I mark topic as resolved?


The general forum convention seems to be to put [SOLVED] first in the forum title :)

Just edit the topic to say [Solved]