Updating container size in Nifty scrollpanel

I’m trying to dynamically update the height of a container panel inside a scrollpanel based on the content inside. I’ve tried a lot of different things but I could not get the scrollbar to react properly to this.

First let me note that the panel I have as the child root of the scrollpane has a vertical childlayout.
I’ve made sure I’m adding the elements to the correct parent ("#nifty-scrollpanel-child-root" inside the scrollpanel), I can see them lined up vertically.

I’ve tried changing the size of the panel to the proper size based on size of elements I add to it:

chitListPanel.setConstraintHeight(new SizeValue((IDs.length*(chitSize+chitSpacing*2))+"px"));

These “chits” are the elements I add into the panel.
However, this does not work. The scrollbar’s position handle is 100% of the scrollpanel’s height and cannot be moved, it thinks that the visible area is a 100% of the panel inside. I double checked, the logic in the code above returns something around 1100px whereas the visible area height is 600px.

I’ve tried to update it in a number of ways


…and a wide variety of other gobbledygook in all sorts of combinations:

tooltipScrollpanel.setUp(1f, .1f, 1f, 1f, ScrollPanel.AutoScroll.OFF);

But I mostly got two results: either the scrollbar is stuck like before, or it allows dragging but stays the full height of the scrollpanel, making it go out of bounds at the bottom when scrolled down.

I’m out of ideas. Somebody please help me.

The only idea I can think of is recreating the screen when you want to change the height, I’ve had similar issues with list boxes or something similar in the past