ConcertinaPanel in a ViewPort


I've put a ConcertinaPanel into a ViewPort to make it scrollable in case the vertical screen resolution is too low to display our tallest section in the panel. Now my problem is I don't know the current combined height of all sections in the ConcertinaPanel to set the correct height für the panel in the ViewPort. The height of the ViewPort changes with the height of the whole DocumentWindow, but the height of the whole ConcertinaPanel depends on the current "openness" state and height of all sections in the panel.

I couldn't find anything helpful in the API to calculate that current combined height. The components that represent the panel sections have a fixed height, but the sections could be closed or partially closed at any time.

I could calculate the maximum height of the panel when all sections are open at the same time, but then the user would be able to scroll down even when the sections are closed and no scrolling would be necessary.

Can anyone think of a way to make this work nicely?