Introduction
JavaFX includes the SepiaTone class. The SepiaTone class is used to provide a sepia tone effect to a picture, similar to that of an antique photograph. SepiaTone Effect basically changes the tone of the image to a reddish brown color.
Source: Adobe
The class javafx.scene.effect.SepiaTone in JavaFX represents the SepiaTone effect. To generate an appropriate impact, we simply need to instantiate this class.
Constructors
The SepiaTone class contains two constructors
-
public Sepiatone(): creates a new instance of SepiaTone class.
- public Sepiatone(double level): Creates a new instance with a specified level value.
Properties
The table below describes the SepiaTone class properties as well as the setter methods.

Usage
This program serves as an example of the SepiaTone Effect in JavaFX. In this case, we are using the Image and ImageView classes to display an image of the Coding Ninjas logo in a JavaFX scene.
The Sepia Tone Effect has been applied to this image. Put this code in a file called SepiaToneEffectExample.java.
Implementation
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.Group;
import javafx.scene.effect.SepiaTone;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class SepiaToneEffectExample extends Application {
@Override
public void start(Stage stage) {
//import the image
Image image = new Image("D://CodingNinjas.png");
//Setting the image view
ImageView imageView = new ImageView(image);
//Setting the position of the image
imageView.setX(150);
imageView.setY(0);
//Instantiate the SepiaTone class
SepiaTone sepiaTone = new SepiaTone();
//Set the level of the effect
sepiaTone.setLevel(0.8);
//Applying SepiaTone effect to the image
imageView.setEffect(sepiaTone);
//Creating a Group and scene object
Group root = new Group(imageView);
Scene scene = new Scene(root, 600, 300);
//Setting title to the Stage
stage.setTitle("Sepia tone effect example");
//Adding scene to the stage
stage.setScene(scene);
//Displaying the contents
stage.show();
}
public static void main(String args[]){
launch(args);
}
}
Execution
To execute the above program. You can follow the given steps:
-
Open the terminal in the same folder where you have saved your source code.
-
Enter the below code and hit enter.
javac --module-path path/to/your/javaFx/modules --add-modules javafx.fxml,javafx.controls filename.java
-
After you hit enter a new file will automatically be generated namely filename.class
-
Now, enter the below command and hit enter to execute the above program.
java --module-path path/to/your/javaFx/modules --add-modules javafx.fxml,javafx.controls filename.java
- You have successfully executed the JavaFX program.
Output





