Table of contents
1.
Introduction
2.
JavaFX BoxBlur
2.1.
 Properties 
2.2.
Constructor
2.3.
Methods
3.
Examples of JavaFX BoxBlur Implementation
4.
Frequently Asked Questions
4.1.
What is the function of ActionEvent in Java?
4.2.
What does the lambda expression in JavaFX mean?
4.3.
What is the JavaFX inset?
5.
Conclusion
Last Updated: Mar 27, 2024
Easy

JavaFX BoxBlur

Author Prerna Tiwari
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

JavaFX 3D shapes are geometrical figures that can be represented on the X, Y, and Z planes at the same time. The length or depth is represented by the X plane, the height by the Y plane, and the width by the Z plane. Cube, Cuboid, Cylinder, Cone, Sphere, and other general 3D shapes Shape3D class includes 3D shapes, and the Shape class includes all shapes (2D and 3D shapes). 

JavaFX effects are graphical effects that can be applied to controls in a JavaFX application to improve the appearance of the application's GUI. The following effects are built into JavaFX:

  • Drop Shadow
  • Shadow
  • BoxBlur
  • GaussianBlur
  • Reflection
  • MotionBlur
  • Bloom
  • Glow
  • SepiaTone
  • DisplacementMap
  • ColorInput
  • ImageInput
  • Blend
  • Lighting
  • PerspectiveTransform

JavaFX BoxBlur

JavaFX includes the BoxBlur class. BoxBlur blurs a node with a simple Box filter. Blur is implemented in JavaFX using BoxBlur. A blur effect is based on a simple box filter kernel, with size parameters in both dimensions and also an iteration parameter to control the quality of the resulting blur.

Example:

BoxBlur boxBlur = new BoxBlur();
 boxBlur.setWidth(20);
 boxBlur.setHeight(6);
 boxBlur.setIterations(2);
 Text message = new Text();
 message.setText("Blurry Text!");
 message.setFill(Color.web("0x3b596d"));
 message.setFont(Font.font(null, FontWeight.BOLD, 50));
 message.setX(10);
 message.setY(50);
 message.setEffect(boxBlur);

 Properties 

Type Property Description
DoubleProperty height This represents the vertical dimension of the blur effect.
IntegerProperty iterations The number of times the blur effect has to iterate to improve its "quality" or "smoothness".
ObjectProperty<Effect> input

The input for this Effect.

 

DoubleProperty width

The horizontal dimension of the blur effect.

 

Constructor

JavaFX BoxBlur has two constructors. Depending on the situation, it can be parameterized or non-parameterized.

  • BoxBlur(): This creates a new instance of BoxBlur with all the parameters having a default value.
  • BoxBlur(double width, double height, int iterations): This creates a new instance of BoxBlur with all the parameters having specified values for width, height, and iterations.

Methods

Java FlowPane has various methods that implement various functionalities. The most commonly used methods in FlowPane are.

Modifier and type Method Description
DoubleProperty

widthProperty()

 

The horizontal dimension of the blur effect.

 

DoubleProperty

heightProperty()

 

The vertical dimension of the blur effect.
double getHeight()

Gets the value of the property height.

 

double getWidth() Gets the value of the property width.
void setWidth() Sets the value of the property width.
void

setIterations(int value)

 

Sets the value of the property iterations.

 

void setHeight() Sets the value of the property height.
void

setInput(Effect value)

 

Sets the value of the property input.

 

IntegerProperty

iterationsProperty()

 

The number of times the blur effect has to iterate to improve its "quality" or "smoothness".

ObjectProperty<Effect>

 

inputProperty()

 

The input for this Effect.

 

Effect

 

getInput()

 

Gets the value of the property input.

 

Examples of JavaFX BoxBlur Implementation

package application;  
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.FontPosture;  
import javafx.scene.text.FontWeight;  
import javafx.scene.text.Text;  
import javafx.stage.Stage;  
public class BoxBlurExample extends Application{  
  
    @Override  
    public void start(Stage primaryStage) throws Exception {  
        // TODO Auto-generated method stub  
        Text text = new Text();  
        text.setText("Welcome to Coding Ninjas!");  
        text.setX(100);  
        text.setY(100);  
        text.setFont(Font.font("Calibri",FontWeight.BLACK,FontPosture.ITALIC,20));  
        text.setFill(Color.RED);  
        text.setStroke(Color.BLACK);  
        text.setUnderline(true);  
        BoxBlur b = new BoxBlur();  
        b.setHeight(5);  
        b.setWidth(2);  
        b.setIterations(1);  
        text.setEffect(b);  
        Group root = new Group();  
        root.getChildren().add(text);  
        Scene scene = new Scene(root,450,200);  
        primaryStage.setScene(scene);  
        primaryStage.setTitle("BoxBlur Example");  
        primaryStage.show();  
    }  
public static void main(String[] args) {  
    launch(args);  
}  
}  

 

BoxBlur Example

Frequently Asked Questions

What is the function of ActionEvent in Java?

Java makes use of ActionEvent. To handle the actionPerformed event, awt calls the actionPerformed methods on listeners-a and listener-b. It notifies any registered ActionListener objects of any action events that occur on this object.

What does the lambda expression in JavaFX mean?

Using a lambda expression, you can create an anonymous class that implements a specific functional interface with only one abstract method. The EventHandler interface has only one abstract method, handle, which is used to manage JavaFX events.

What is the JavaFX inset?

The JavaFX Insets class is a component. The Insets class stores the interior offsets for each of the four sides of the rectangular region. The Insets class is based on Java.

Conclusion

In this article, we have extensively discussed the concepts of JavaFX BoxBlur. We started with introducing the JavaFx BoxBlur, constructors of JavaFX BoxBlur, and methods of JavaFX BoxBlur then concluded with JavaFX BoxBlur implementation.

We hope that this blog has helped you enhance your knowledge regarding JavaFX BoxBlur, and if you would like to learn about JavaFX, you can learn from JavaFXJavaFX Fill transitionJavaFX Scale Transition, JavaFX rotate transition, etc.

You can also refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingSystem Design, and many more! You may also check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! For placement preparations, you must look at the problemsinterview experiences, and interview bundle.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Happy Coding!

 

Live masterclass