Dimension () { Rectangle bounds = myScrollPane.getViewport().getBounds(); Dimension size = getSceneSize(this); size.width = Math.max(size.width, bounds.width); size.height = Math.max(size.height, bounds.height); return size; }