Nifty Panel minimum size


I want to modify my Nifty GUI for different resolutions. Now I have some problems with a small resolution.

Can i set the size of a panel to 50% of the screen size but it must be at least 500 pixel large?

You could do that using your screen controller (i.e. width="${CALL.getPanelWidth()}"

String getPanelWidth() {

// Do stuff

return calculatedWidth+“px”;


I can’t think of any way to do it directly from the xml, although I’m hardly an expert as I’ve only picked up Nifty recently…

I can’t think of any way to do it directly from the xml

Hm, thats bad because in my case the user should be able to change the GUI by editing the xml files.

You could do it generically. Write a method in your controller getPanelWidth(String min, String percent);

Then from the xml you can just do ${CALL.getPanelWidth(400, 50)} to have the width generated for you by the java but have the behaviour of the function specified by the xml.

That syntax is from memory of reading the nifty guide though as I’ve not actually used parameters into a function yet - I do remember it saying they are possible though.