首页javaeffectJavaFX - 如何在文本上创建BoxBlur效果

JavaFX - 如何在文本上创建BoxBlur效果

我们想知道如何在文本上创建BoxBlur效果。
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.BoxBlur;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Main extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    }
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Text Fonts");
        Group root = new Group();
        Scene scene = new Scene(root, 550, 250);

        Text text = new Text(50, 100, "JavaFX 2.0 from w3cschool.cn");
        Font sanSerif = Font.font("Dialog", 30);
        text.setFont(sanSerif);
        text.setFill(Color.RED);
        root.getChildren().add(text);

        BoxBlur bb = new BoxBlur();
        bb.setWidth(15);
        bb.setHeight(15);
        bb.setIterations(3);

        text.setEffect(bb);

        

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