Consumer<View> () { return view -> { float width = view.getPreferredSpan(View.X_AXIS); if (width < 0 || width > myBottomScrollPane.getWidth()) { myBottomScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); } }; }