Introduction
JavaFX is a Java framework and GUI toolkit. It creates and supports Rich Internet, web, and desktop apps. The main motive for implementing JavaFX is that programs created with it can run on many platforms. Desktops, the web, mobile phones, TVs, tablets, and operating systems like Windows, Linux, iOS, and Android are some samples.
In this article, we will learn the features of JavaFX ColorAdjust, like constructors and some properties. We will also discuss the working example of JavaFX ColorAdjust code in the end. So, let's dive into the article without wasting time.
JavaFX ColorAdjust
JavaFX enables us to enhance the look of an image By altering the hue, saturation, brightness, and contrast of the image's color. The javafx.scene.effect class can be applied to the node using a variety of properties and methods held in the ColorAdjust object.
Here is an example of JavaFX ColorAdjust to set hoe, brightness, contrast, and many more on your own.
ColorAdjust colorAdjust = new ColorAdjust();
colorAdjust.setContrast(0.2);
colorAdjust.setHue(-0.06);
colorAdjust.setBrightness(0.2);
colorAdjust.setSaturation(0.1);
Image image = new Image("car.jpg");
ImageView imageView = new ImageView(image);
imageView.setFitWidth(150);
imageView.setPreserveRatio(true);
imageView.setEffect(colorAdjust);
Constructor
The two constructors present in JavaFX ColorAdjust are given below:
-
public ColorAdjust(): It creates the new instance of ColorAdjust with the default parameters.
- public ColorAdjust(double hue, double saturation, double brightness, double contrast): It creates a new instance of the ColorAdjust with the fixed parameters.
Properties

Implementation
The ColorAdjust Effect has been applied to an image with many features in the example below. The output displays a comparison between the affected image and the original image.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
public class ColorAdjustEffectExample extends Application {
@Override
public void start(Stage stage) {
String imageUrl = "https://www.codingninjas.com/images/logo.png";
Image image = new Image(imageUrl);
ImageView imageView1 = new ImageView(image);
imageView1.setX(100);
imageView1.setY(20);
ImageView imageView2 = new ImageView(image);
imageView2.setX(100);
imageView2.setY(170);
// Create the ColorAdjust
ColorAdjust colorAdjust = new ColorAdjust();
// Setting the contrast value
colorAdjust.setContrast(0.3);
// Setting the hue value
colorAdjust.setHue(-0.05);
// Setting the brightness value
colorAdjust.setBrightness(0.5);
// Setting the saturation value
colorAdjust.setSaturation(0.7);
// Applying ColorAdjust effect to the ImageView node
imageView2.setEffect(colorAdjust);
Group root = new Group(imageView1, imageView2);
Scene scene = new Scene(root, 450, 320);
stage.setTitle("JavaFX ColorAdjust Effect");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]) {
launch(args);
}
}
Output






