Window - relu91/nifty-gui GitHub Wiki
The Nifty Window control is actually a Draggable Standard Controls Drag'n'Drop with a default style so that it looks like a regular Window. It can be dragged around the screen and it can be closed. Windows can overlap each other and they can contain other elements and controls as their content.
Please Note: By default windows use a CenterLayout for the content. So make sure that you add a panel with another childLayout if you plan to have several elements/controls in your window.
You can create the Window control from XML or with the JavaBuilder pattern. Once you have created the control you can change some aspects of the control using the following NiftyControl interface based API.
The following parameters can be set when creating a window control.
Name | Datatype | Default | Description |
closeable | Boolean | true | When set to false the Window will not contain a close button and can't be closed by interacting with the Window control. |
hideOnClose | Boolean | false | If set to true the Window will not be removed (the default behavior) but instead it will only be hidden. |
The same notifications are being sent that the standard Draggable control sends, see Standard Controls Drag'n'Drop for details.
// create a window
control(new WindowBuilder("myWindow", "Title of Window") {{
closable(false); // you can't close this window
width("320px"); // windows will need a size
height("200px");
text(new TextBuilder() {{
text("Hello Window");
style("base-font");
color("#eeef");
valignCenter();
width("100%");
}});
}});
// a regular closable window (see note below why there is a layer required for this)
<layer id="windows" childLayout="absolute">
<control id="window-3" name="window" title="Please Drag Me Too!" width="500px" height="400px" x="400px">
<text text="I'm Another Window!" style="base-font" color="#eeef" valign="center" width="100%" />
</control>
</layer>
Please Note: To absolutely position windows you'll need to keep them in a layer with childLayout="absolute".