RichTextFX get scrollbar in codeArea

1.1k Views Asked by At

I'm using RichTextFX and I was surprised that the CodeArea does not come with a scrollbar enabled by default. How can I get this to appear?

1

There are 1 best solutions below

0
On

This worked for me. I used an AnchorPane as a root node.

    CodeArea codeArea = new CodeArea();
    VirtualizedScrollPane sp = new VirtualizedScrollPane(codeArea);

    anchorPane.getChildren().add(sp);

    anchorPane.setLeftAnchor(sp, 0.0);
    anchorPane.setRightAnchor(sp, 0.0);
    anchorPane.setBottomAnchor(sp, 0.0);
    anchorPane.setTopAnchor(sp, 0.0);

    codeArea.prefWidthProperty().bind(anchorPane.widthProperty());
    codeArea.prefHeightProperty().bind(anchorPane.heightProperty());