Fixes the handling of the scroll position of a Window (#12736)

After the first commit the same fix has been applied also for panels, in
addition to other suggested changes.

The scroll position of a Window is now memorized before applying
the fix for bug #11994. The position is restored after the fix.

Because the scrolling issue is known to appear also in other components,
the fix for the scrolling has been moved to the Util class.

Change-Id: I5251011b5bede77a7fb18972e1d90016c0eccc23