modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextAreaSkin.java

Print this page
rev 9047 : RT-36454: [Modena, TextArea] Vertical scrollbar appears in TextArea and then disappears

*** 1,7 **** /* ! * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 351,360 **** --- 351,375 ---- || scrollPane.getPrefViewportHeight() > 0) { // Force layout of viewRect in ScrollPaneSkin getParent().requestLayout(); } } + + // RT-36454: Fit to width/height only if smaller than viewport. + // That is, grow to fit but don't shrink to fit. + Bounds viewportBounds = scrollPane.getViewportBounds(); + boolean wasFitToWidth = scrollPane.isFitToWidth(); + boolean wasFitToHeight = scrollPane.isFitToHeight(); + boolean setFitToWidth = textArea.isWrapText() || computePrefWidth(-1) <= viewportBounds.getWidth(); + boolean setFitToHeight = computePrefHeight(width) <= viewportBounds.getHeight(); + if (wasFitToWidth != setFitToWidth || wasFitToHeight != setFitToHeight) { + Platform.runLater(() -> { + scrollPane.setFitToWidth(setFitToWidth); + scrollPane.setFitToHeight(setFitToHeight); + }); + getParent().requestLayout(); + } } } private ContentView contentView = new ContentView(); private Group paragraphNodes = new Group();