Introduction
The JavaFX GaussianBlur Effect is very similar to the JavaFX BoxBlur Effect. The only difference between the two is that the GaussianBlur effect blurs the nodes using a Gaussian convolution kernel. To implement GaussianBlur on the nodes, JavaFX provides the class javafx.scene.effect.GaussianBlur. This class is instantiated in order to have an effect on the node.
Properties
The following table describes the class's properties as well as the setter methods.
🔥 Property
→ Description
→ Setter Methods
🔥 input
This is an effect property. It represents the effect's input.
setInput(Effect value)
🔥 radius
This property has two types. It represents the blur kernel's radius.
setRadius(Double value)
Constructors
There are two constructors in the class.
🌻 public GaussianBlur() :creates a new instance with the default parameter values.
🌻 public GaussianBlur(double radius): This creates a new instance with the parameters specified.
Examples of JavaFX GaussianBlur Implementation
package application;
import javafx.scene.Group;
import javafx.application.Application;
import javafx.scene.effect.BoxBlur;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.text.FontPosture;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.FontWeight;
public class GaussianBlureg extends Application{
public void start(Stage primaryStage) throws Exception {
Text message = new Text();
message .setText("Welcome");
message setX(100);
message .setY(100);
message.setFont(Font.font("Calibri",FontWeight.BLACK,FontPosture.ITALIC,20));
message .setFill(Color.RED);
message .setStroke(Color.BLACK);
message .setUnderline(true);
GaussianBlur g = new GaussianBlur();
g.setRadius(5);
text.setEffect(g);
Group root = new Group();
root.getChildren().add(text);
Scene scene = new Scene(root,450,200);
primaryStage.setScene(scene);
primaryStage.setTitle("GaussianBlur Example");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}







