trilogy
trilogy

Reputation: 1795

RichTextFx VirtualizedScrollPane flickers when text wraps as you type

enter image description here

I have a flickering issue with RichTextFx StyleClassedTextArea and VirtualizedScrollPane. When you wrap text and keep typing, it flickers so much that you are unable to read while you type. This is a stark contrast to the regular TextArea scrolling. It's more pronounced than the gif above (gif fps doesn't give it justice).

I'm not sure if this is because of the GridPane...

Java8u212

<dependency>
     <groupId>org.fxmisc.richtext</groupId>
     <artifactId>richtextfx</artifactId>
     <version>0.10.6</version>
</dependency>

Code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea;

public class NewFXMain extends Application
{

    @Override
    public void start(Stage primaryStage)
    {
        StyleClassedTextArea textArea = new StyleClassedTextArea();
        textArea.setWrapText(true);

        TextArea textAreaFx = new TextArea();
        textAreaFx.setWrapText(true);
        
        VirtualizedScrollPane scrollpane = new VirtualizedScrollPane(textArea);
        scrollpane.setPrefWidth(300);
        
        GridPane notePane = new GridPane();

        notePane.setVgap(2);
        notePane.setHgap(6);

        notePane.add(textAreaFx, 0, 0);
        notePane.add(scrollpane, 0, 1);

        Scene scene = new Scene(notePane, 600, 400);
        primaryStage.setScene(scene);
        primaryStage.setTitle("Scroll flickering demo");
        primaryStage.show();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        launch(args);
    }

}

Upvotes: 1

Views: 267

Answers (1)

trilogy
trilogy

Reputation: 1795

Found out how to fix the text flickering, although the scrollbars still flicker which is way more acceptable:

textArea.requestFollowCaret();

Upvotes: 2

Related Questions