Nifty was meant to read everything from XML files. But sometimes this is not enough because you need to decide from within your code what needs to be created.
This was possible in older versions of Nifty but was kinda tricky.
With Nifty 1.0 (currently available in svn) this has been improved. There are now special classes available to create and configure the build-in elements like Panel, Text, Label and Image.
Example use:
CreatePanel createPanel = new CreatePanel();
createPanel.setChildLayout("horizontal");
createPanel.setHeight("8px");
createPanel.create(nifty, screen, parent);</pre></p>
There is now even support to dynamically create your controls with a CreateCustomControl class.
Nifty stuff :)