JavaFX Effects - InnerShadow

On applying this effect to a node, a shadow will be created inside the edges of the node.

The class named InnerShadow of the package javafx.scene.effect represents the inner shadow effect. This class contains ten properties, which are −

  • color − This property is of Color type representing the color of the shadow.

  • blur type − This property is of BlurType and it represents the type of blur effect used to blur the shadow.

  • radius − This property is of the type double and it represents the radius of the shadow blur kernel.

  • width − This property is of the type double and it represents the width of the shadow blur kernel.

  • height − This property is of the type double and it represents the height of the shadow blur kernel.

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

  • spread − This property is of the type double; it represents the spread of the shadow.

  • offsetX − This property is of the type double, it represents the shadow offset in the x direction, in pixels.

  • offsetY − This property is of the type double, it represents the shadow offset in the y direction in pixels.

  • choke − This property is of double type; it represents the choke of the shadow.


The following program is an example demonstrating the inner shadow effect of JavaFX. In here, we are drawing a text “Welcome to Tutorialspoint”, and a circle in a scene.

To these, we are applying the inner shadow effect. 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.InnerShadow; 
import javafx.scene.paint.Color; 
import javafx.scene.shape.Circle; 
import javafx.stage.Stage; 
import javafx.scene.text.Font; 
import javafx.scene.text.FontWeight; 
import javafx.scene.text.Text; 
public class InnerShadowEffectExample 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 embedded. 
      text.setText("Welcome to Tutorialspoint");        
      //Setting the color of the text 
      //Drawing a Circle 
      Circle circle = new Circle();         
      //Setting the center of the circle 
      //Setting the radius of the circle 
      //setting the fill color of the circle 
      //Instantiating the InnerShadow class  
      InnerShadow innerShadow = new InnerShadow(); 
      //Setting the offset values of the inner shadow 
      //Setting the color of the inner shadow 
      //Applying inner shadow effect to the text 
      //Applying inner shadow effect to the circle 
      //Creating a Group object  
      Group root = new Group(text,circle);   
      //Creating a scene object 
      Scene scene = new Scene(root, 600, 300);
      //Setting title to the Stage 
      stage.setTitle("Inner shadow effect example"); 
      //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 InnerShadowEffectExample  

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

Inner Shadow Effect