Home » Java » JavaFX – Visual resize glitch when rendering large number of Texts

JavaFX – Visual resize glitch when rendering large number of Texts

Posted by: admin June 30, 2018 Leave a comment

Questions:

Is there a way to eliminate this visual glitch when resizing a container with a significant number of Text components? What is causing it?

enter image description here

Code used:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class ResizeTest extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Pane root = new Pane();

        for (int i = 0; i < 60; i++) {
            for (int j = 0; j < 100; j++) {
                Text t = new Text("A");
                t.setY(i * 15);
                t.setX(j * 10);
                root.getChildren().add(t);
            }
        }

        Scene scene = new Scene(root, 400, 200);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

This is being shown on a Linux Mint PC.

Answers: