我有多行标签(例如100行),文本从下到上滚动,类似电影信用。我想模糊该标签的10%的顶部和底部,以便进入和离开的文本模糊。我怎样才能做到这一点?我试图在这些位置上粘贴一些元素并模糊它们但是没有用。
答案 0 :(得分:2)
我没有看到模糊,但通常文字正在消失。下面是一个如何淡化的示例:创建一个叠加窗格,其中的线性渐变来自背景颜色 - >透明的 - >背景颜色。像这样:
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功能,创建文本快照,模糊图像并将其放在文本的顶部。