模糊多行标签的顶部和底部

Blur top and bottom of multiline label

我有多行标签(例如 100 行),文本从下到上滚动,类似于电影演职员表。我想模糊该标签顶部和底部的 10%,以便进入和离开的文本模糊。我怎样才能做到这一点?我试图在那个位置粘贴一些元素并模糊它们,但那没有用。

我没有看到模糊,但通常文字会褪色。这是一个如何进行淡入淡出的示例:创建一个覆盖窗格,其线性渐变从背景色 -> 透明 -> 背景色。像这样:

public class Main extends Application {

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

    @Override
    public void start(Stage primaryStage) {

        TextArea textArea = new TextArea(
                "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. ");
        textArea.setWrapText(true);

        StackPane root = new StackPane();

        Pane overlay = new Pane();
        overlay.setMouseTransparent(true);

        Stop[] stops = new Stop[] { new Stop(0.0, Color.WHITE), new Stop(0.25, Color.TRANSPARENT), new Stop(0.75, Color.TRANSPARENT), new Stop(1.0, Color.WHITE) };
        LinearGradient linearGradient = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
        overlay.setBackground(new Background(new BackgroundFill(linearGradient, null, null)));

        root.getChildren().addAll(textArea, overlay);

        Scene scene = new Scene(root, 300, 100);

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

如果你坚持模糊,可以使用snapshot功能,创建文本的快照,模糊图像并将其放在文本之上。