File tree Expand file tree Collapse file tree
richtextfx/src/main/java/org/fxmisc/richtext Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1444,6 +1444,40 @@ public void dispose() {
14441444 * *
14451445 * ********************************************************************** */
14461446
1447+ private BooleanProperty autoHeightProp = new SimpleBooleanProperty ();
1448+
1449+ public BooleanProperty autoHeightProperty () {
1450+ return autoHeightProp ;
1451+ }
1452+ public void setAutoHeight ( boolean value ) {
1453+ autoHeightProp .set ( value );
1454+ }
1455+ public boolean isAutoHeight () {
1456+ return autoHeightProp .get ();
1457+ }
1458+
1459+ @ Override
1460+ protected double computePrefHeight ( double width )
1461+ {
1462+ if ( autoHeightProp .get () )
1463+ {
1464+ if ( getWidth () == 0.0 ) Platform .runLater ( () -> requestLayout () );
1465+ else
1466+ {
1467+ double height = 0.0 ;
1468+ Insets in = getInsets ();
1469+
1470+ for ( int p = 0 ; p < getParagraphs ().size (); p ++ ) {
1471+ height += getCell ( p ).getHeight ();
1472+ }
1473+ if ( height > 0.0 ) {
1474+ return height + in .getTop () + in .getBottom ();
1475+ }
1476+ }
1477+ }
1478+ return super .computePrefHeight ( width );
1479+ }
1480+
14471481 @ Override
14481482 protected void layoutChildren () {
14491483 Insets ins = getInsets ();
You can’t perform that action at this time.
0 commit comments