JavaFX | InnerShadow Class
InnerShadow class is a part of JavaFX. InnerShadow class creates a high-level effect that renders a shadow inside the edges of the object with given specified radius, offset, choke, color and blur type. InnerShadow class inherits the Effect class.
Constructors of the class:
- InnerShadow(): Creates a new Object of InnerShadow.
- InnerShadow(BlurType blurType, Color color, double radius, double choke, double offsetX, double offsetY): Creates a new Object of InnerShadow with specified blurType, color, radius, choke, and offset.
- InnerShadow(double r, Color c): Creates a new Object of InnerShadow with specified radius and color.
- InnerShadow(double radius, double offsetX, double offsetY, Color color): Creates a new Object of InnerShadow with specified radius, offset and color.
Commonly Used Methods:
| Method | Explanation |
|---|---|
| getBlurType() | Returns the blur type of the Effect. |
| setBlurType(BlurType v) | Sets the blur type of the Effect. |
| getChoke() | Returns the value of the property choke. |
| setChoke(double d) | Sets the value of the property choke. |
| setColor(Color v) | Sets the color of the effect. |
| getColor() | Returns the color of the effect. |
| setInput(Effect v) | Sets the value of property input. |
| getInput() | Returns the value of property input. |
| setOffsetX(double v) | Sets the value of offsetX of the effect. |
| setOffsetY(double v) | Sets the value of offsetY of the effect. |
| getOffsetX() | Sets the value of offsetX of the effect |
| getOffsetY() | Sets the value of offsetY of the effect. |
| setRadius(double v) | Sets the value of radius of the effect. |
| getRadius() | Sets the value of radius of the effect. |
Below programs illustrate the use of InnerShadow class:
- Java program to create a Circle and add InnerShadow effect to it: In this program we will create a Circle named circle and create a InnerShadow effect Inner_shadow with specified radius and color. The InnerShadow effect will be added to the circle using the setEffect() function and the circle will be added to the group. The circles will be translated to specific position in the stage using setTranslateX() and setTranslateY() function. The group will be added to the scene and the scene will be added to the stage.
// Java program to create a Circle// and add InnerShadow effect to itimportjavafx.application.Application;importjavafx.scene.Scene;importjavafx.scene.control.*;importjavafx.scene.layout.*;importjavafx.stage.Stage;importjavafx.scene.image.*;importjavafx.scene.effect.*;importjava.io.*;importjavafx.scene.shape.Circle;importjavafx.scene.paint.Color;importjavafx.scene.Group;publicclassInner_shadow_1extendsApplication {// launch the applicationpublicvoidstart(Stage stage)throwsException{// set title for the stagestage.setTitle("Inner_shadow example");// create a circleCircle circle =newCircle(50.0f,50.0f,50.0f);// set fill for circlecircle.setFill(Color.BLUE);// translate to a positioncircle.setTranslateX(50.0f);circle.setTranslateY(50.0f);// create a sepia_tone effectInnerShadow sepia_tone =newInnerShadow(10, Color.RED);// set effectcircle.setEffect(sepia_tone);// create a GroupGroup group =newGroup(circle);// create a sceneScene scene =newScene(group,200,200);// set the scenestage.setScene(scene);stage.show();}// Main Methodpublicstaticvoidmain(String args[]){// launch the applicationlaunch(args);}}chevron_rightfilter_noneOutput:

- Java program to create four Circles and add InnerShadow effect to it which are of different blur types and diiferent values of choke, offsetX, offsetY and radius: In this program we will create the Circles named circle, circle1, circle2, circle3 and the InnerShadow effects named Inner_shadow1, Inner_shadow2, Inner_shadow3, Inner_shadow4 with specified radius, color, offsetX, offsetY, choke and blur type. The InnerShadow effect will be added to the circle using the setEffect() function and the circles will be added to the group. The circles will be translated to specific position in the stage using setTranslateX() and setTranslateY() function. The group will be added to the scene and the scene will be added to the stage.
// Java program to create four Circles and add// InnerShadow effect to it which are of different// blur types and diiferent values of choke,// offsetX, offsetY and radiusimportjavafx.application.Application;importjavafx.scene.Scene;importjavafx.scene.control.*;importjavafx.scene.layout.*;importjavafx.stage.Stage;importjavafx.scene.image.*;importjavafx.scene.effect.*;importjava.io.*;importjavafx.scene.shape.Circle;importjavafx.scene.paint.Color;importjavafx.scene.Group;publicclassInner_shadow_2extendsApplication {// launch the applicationpublicvoidstart(Stage stage)throwsException{// set title for the stagestage.setTitle("Inner_shadow example");// create a circleCircle circle =newCircle(0.0f,0.0f,25.0f, Color.RED);Circle circle1 =newCircle(0.0f,0.0f,25.0f, Color.RED);Circle circle2 =newCircle(0.0f,0.0f,25.0f, Color.RED);Circle circle3 =newCircle(0.0f,0.0f,25.0f, Color.RED);// translate to a positioncircle.setTranslateX(50.0f);circle.setTranslateY(50.0f);// translate to a positioncircle1.setTranslateX(150.0f);circle1.setTranslateY(50.0f);// translate to a positioncircle2.setTranslateX(50.0f);circle2.setTranslateY(150.0f);// translate to a positioncircle3.setTranslateX(150.0f);circle3.setTranslateY(150.0f);// create Inner_shadow effectInnerShadow Inner_shadow1 =newInnerShadow(BlurType.values()[0],Color.BLACK,5,3.0f,2.0f,2.0f);InnerShadow Inner_shadow2 =newInnerShadow(BlurType.values()[1],Color.BLACK,5,3.0f,3.0f,3.0f);InnerShadow Inner_shadow3 =newInnerShadow(BlurType.values()[2],Color.BLACK,5,4.0f,3.0f,3.0f);InnerShadow Inner_shadow4 =newInnerShadow(BlurType.values()[3],Color.BLACK,5,4.0f,2.0f,2.0f);// set effectcircle.setEffect(Inner_shadow1);circle1.setEffect(Inner_shadow2);circle2.setEffect(Inner_shadow3);circle3.setEffect(Inner_shadow4);// create a GroupGroup group =newGroup(circle, circle1,circle2, circle3);// create a sceneScene scene =newScene(group,400,400);// set the scenestage.setScene(scene);stage.show();}// Main Methodpublicstaticvoidmain(String args[]){// launch the applicationlaunch(args);}}chevron_rightfilter_noneOutput:

Note: The above programs might not run in an online IDE. Please use an offline compiler.
Reference: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/effect/InnerShadow.html
Recommended Posts:
- JavaFX | Pos Class
- JavaFX | Tab Class
- JavaFX | Rectangle2D Class
- JavaFX | ColorInput Class
- JavaFX | MotionBlur Class
- JavaFX | SepiaTone Class
- JavaFX | Duration Class
- JavaFX | TabPane Class
- JavaFX | Slider Class
- JavaFX | ToggleButton Class
- JavaFX | Popup Class
- JavaFX | Hyperlink Class
- JavaFX | ColorAdjust Class
- JavaFX | Bloom Class
- JavaFX | Insets Class
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



