How to create this auto scrollbar behaviour?


I need a Component that has a subcomponent which can be larger then the component itself, so I need a scrollbar. But I do not want the scrollbar to dissapear completely when the subcomponent is not larger.

For example:

Here the subcomponent holds a list. When the list is small, it will fit in the parent component. So no scrollbar is needed. But I want the space for the scrollbar to be present. So I think something like a disabled or inactive scrollbar?

When the list grows and the subcomponent gets larger then the parent, the scrollbar should be present and active. Because the space was already reserved, it will not change the layout of the main window.

How can I do this?
Note that I need to be able to use the subcomponent for other things then a list.