Implementation
Let's now examine the lighting class's real implementation.
The application below retrieves the image from the specified URL, loads it, and then attaches it to two distinct imageView instances. after making a few adjustments to the image, such as changing the height and positioning. The lighting object is made, and then we set the light source for it. After that, the second imageView object is given this lighting effect. Then, we create two distinct text objects that display the image's description underneath them. Finally, we combine all of these nodes into a scene, give it a title, and invoke the show function to display the results.
Program
// importing required libraries
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Lighting;
import javafx.scene.effect.Light.Point;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.paint.Color;
public class Lighting_Example extends Application {
@Override
public void start(Stage stage) throws Exception {
// loading the image
Image image = new Image("https://files.codingninjas.in/cn-17917.png");
// imageview to display above image
ImageView imageView = new ImageView(image);
ImageView imageView2 = new ImageView(image);
// setting position of both the images
imageView.setX(50);
imageView.setY(60);
imageView2.setX(350);
imageView2.setY(60);
// setting the size of both the images
imageView.setFitHeight(200);
imageView.setFitWidth(200);
imageView2.setFitHeight(200);
imageView2.setFitWidth(200);
// preserve ratio of the image
imageView.setPreserveRatio(true);
imageView2.setPreserveRatio(true);
// light source
Point source = new Point(400, 150, 250, Color.ORANGE);
// creating and setting the lighting effect
Lighting lighting = new Lighting();
imageView2.setEffect(lighting);
// setting the light source
lighting.setLight(source);
// text displayed below the first image
Text text = new Text();
text.setFont(Font.font(null, FontWeight.BOLD, 15));
text.setX(50);
text.setY(290);
text.setText("Without Lighting Effect");
text.setFill(Color.RED);
// text displayed below second image
Text text2 = new Text();
text2.setFont(Font.font(null, FontWeight.BOLD, 15));
text2.setX(370);
text2.setY(290);
text2.setText("With Lighting Effect");
text2.setFill(Color.RED);
// grouping all the nodes together
Group group = new Group(imageView, imageView2, text, text2);
/// creating scene
Scene scene = new Scene(group, 600, 350);
// setting scene
stage.setScene(scene);
// setting the title for our stage
stage.setTitle("Lighting Example");
// displaying the result
stage.show();
}
public static void main(String[] args) {
// launching the application
launch(args);
}
}

You can also try this code with Online Java Compiler
Run Code
How to execute the above program?
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 yourFilename.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

Frequently Asked Questions
What is JavaFX?
JavaFX is a software framework for developing and delivering desktop and rich web applications that can operate on a wide range of devices. JavaFX is compatible with Microsoft Windows, Linux, and macOS desktop PCs and web browsers, as well as iOS and Android mobile devices.
What is JavaFX Stage?
A Scene, which is made up of visual components, is hosted by a Stage in JavaFX. A stage in a JavaFX application is represented by the Stage class in the javafx. stage package. The start(Stage stage) method of the Application class receives the platform-created primary stage as a parameter.
How many stages are there in JavaFX?
JavaFX Stage is a display window for a single application. The main component in JavaFX is the stage. There is only one primary stage, but we can add as many as we like.
Conclusion
In this article, we have extensively discussed the Light.Point class available in JavaFx Framework. We have also seen the implementation of light.Point and we can use this light.point light source into our program.
If you think this blog has helped you enhance your knowledge about JavaFx light.point light source and if you would like to learn more, check out our articles JavaFX, JavaFX HBox, JavaFX FileChooser, JavaFX VBox, JavaFX Fade Transition, JavaFX Sequential Transition, and many more on our Website.
Check out this problem - Smallest Distinct Window.
Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problems, interview experiences, and interview bundle for placement preparations.
Nevertheless, you may consider our paid courses to give your career an edge over others!

Please upvote our blog to help other ninjas grow.
Happy Learning!