JavaFX Effects - Box Blur

In general, Blur means becoming unclear, on applying blur effect to a node it is made unclear. Box Blur is a kind of blur effect provided by JavaFX. In this effect, to apply blur to node, a simple box filter is used.

The class named BoxBlur of the package javafx.scene.effect represents the BoxBlur effect, this class contains four properties, which are −

  • height − This property is of double type representing the vertical size of the effect.

  • width − This property is of double type representing the horizontal size of the effect.

  • input − This property is of the type effect and it represents an input to the BoxBlur effect.

  • iterations − This property is of an integer type representing the number of iterations of the effect, which are to be applied on the node. This is done to improve its quality or smoothness.


Following is an example demonstrating the box blur effect. In here, we are drawing the text “Welcome to Tutorialspoint” filled with DARKSEAGREEN color and applying the Box Blur effect to it.

Save this code in a file with the name

import javafx.application.Application; 
import javafx.scene.Group; 
import javafx.scene.Scene; 
import javafx.scene.effect.BoxBlur; 
import javafx.scene.paint.Color; 
import javafx.stage.Stage; 
import javafx.scene.text.Font; 
import javafx.scene.text.FontWeight; 
import javafx.scene.text.Text; 
public class BoxBlurEffectExample extends Application { 
   public void start(Stage stage) {       
      //Creating a Text object 
      Text text = new Text(); 
      //Setting font to the text 
      text.setFont(Font.font(null, FontWeight.BOLD, 40)); 
      //setting the position of the text 
      //Setting the text to be added. 
      text.setText("Welcome to Tutorialspoint");       
      //Setting the color of the text 
      //Instantiating the BoxBlur class 
      BoxBlur boxblur = new BoxBlur();      
      //Setting the width of the box filter 
      //Setting the height of the box filter 
      //Setting the no of iterations  
      //Applying BoxBlur effect to the text 
      //Creating a Group object  
      Group root = new Group(text);   
      //Creating a scene object 
      Scene scene = new Scene(root, 600, 300);  
      //Setting title to the Stage 
      stage.setTitle("Sample Application"); 
      //Adding scene to the stage 
      //Displaying the contents of the stage;         
   public static void main(String args[]){ 

Compile and execute the saved java file from the command prompt using the following commands.

java BoxBlurEffectExample 

On executing, the above program generates a JavaFX window as shown below.

Box Blur Effect