JavaFX | ColorInput Class Last Updated : 28 Aug, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report ColorInput class is a part of JavaFX. It is used to create an effect which renders a rectangular region, filled with the given Color. It is equivalent to rendering a filled rectangle into an image and using an ImageInput effect, except that it is more convenient and potentially much more efficient. It is mainly passed into the other effects as an input. Constructors of the class: ColorInput(): Creates a new instance of ColorInput with default parameters. ColorInput(double x, double y, double width, double height, Paint paint): Creates a new instance of ColorInput with the specified x, y, width, height, and paint. Commonly Used Methods: Method Description getX() Gets the value of the property x. getY() Gets the value of the property y. setHeight(double value) Sets the value of the property height setPaint(Paint value) Sets the value of the property paint. setWidth(double value) Sets the value of the property width. setX(double value) Sets the value of the property x. setY(double value) Sets the value of the property y. getHeight() Gets the value of the property height. getPaint() Gets the value of the property paint. getWidth() Gets the value of the property width Java program to Demonstrate ColorInput class: In this program, ColorInput Effect is created and then we set the color, height, width, and coordinates of the region of ColorInput. A group object and scene object is created. A scene is added to the stage and then we set the title of the stage. Java // Java program to Demonstrate ColorInput class import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.effect.ColorInput; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class ColorInputDemo extends Application { // Main Method public static void main(String[] args) { // launch the application launch(args); } // launch the application public void start(Stage primaryStage) throws Exception { // Instantiating the ColorInput class ColorInput color = new ColorInput(); // set the color color.setPaint(Color.GREEN); // sets the height of the region of color input color.setHeight(50); // sets the width of the region of color input color.setWidth(200); // set the coordinates of the Colorinput color.setX(90); color.setY(140); // create a rectangle Rectangle rect = new Rectangle(); // applying coloradjust effect rect.setEffect(color); // create a group object Group root = new Group(); // create a scene object Scene scene = new Scene(root, 400, 300); root.getChildren().add(rect); // adding scene to the stage primaryStage.setScene(scene); // set title of the stage primaryStage.setTitle("ColorInput Demo"); primaryStage.show(); } } Output: Java program to apply ColorInput class to the created rectangle by clicking on the button using EventHandler: In this program, we first set the Height, Width, and coordinates of a rectangle and then create a rectangle of the same dimension. Now, create a Button and set the Layouts of the Button. Now, using EventHandler, first, instantiate a ColorInput class using proper dimension and then set ColorInput Effect to the Button. Create a group object and add Button and rectangle to it. Then Create a Scene and add it to the stage. Java // Java program to apply ColorInput class to // the created rectangle by clicking on the // button using EventHandler import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.effect.ColorInput; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class ColorInputExample extends Application { public void start(Stage stage) { double x = 10; double y = 10; double w = 40; double h = 180; // Rectangle Rectangle rect = new Rectangle(x, y, w, h); rect.setFill(Color.WHITE); rect.setStrokeWidth(1); rect.setStroke(Color.BLACK); // Button Button button = new Button("Click To See the Effects!"); // set button layout coordinates button.setLayoutX(100); button.setLayoutY(30); button.setPrefSize(250, 150); button.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { // instantiating the colorinput class ColorInput colorInput = new ColorInput(x, y, w, h, Color.STEELBLUE); // Setting ColorInput effect button.setEffect(colorInput); } }); // create the Group object Group root = new Group(); root.getChildren().addAll(button, rect); Scene scene = new Scene(root, 450, 300); stage.setTitle("JavaFX ColorInput Effect"); stage.setScene(scene); stage.show(); } // Main Method public static void main(String args[]) { // Launch the application launch(args); } } Output: Note: The above programs might not run in an online IDE. Please use an offline compiler. Reference: https://docs.oracle.com/javafx/2/api/javafx/scene/effect/ColorInput.html Comment More infoAdvertise with us Next Article Java AWT | Color Class U ukasp Follow Improve Article Tags : Java JavaFX Practice Tags : Java Similar Reads JavaFX | ColorAdjust Class ColorAdjust class is a part of JavaFX. ColorAdjust class allows per-pixel adjustments of hue, saturation, brightness, and contrast. ColorAdjust class inherits Effect class.Constructors of the class:Â Â ColorAdjust(): Creates a new Object of ColorAdjust classColorAdjust(double hue, double saturation, 5 min read JavaFX | Glow Class Glow class is a part of JavaFX. Glow is a high-level effect that makes the input image appear to glow using a configurable threshold. Glow class inherits Effect class. Constructors of the class: Glow(): Creates a new glow object with default parameters.Glow(double l): Creates a new instance of Glow 4 min read Java AWT | Color Class The Color class is a part of Java Abstract Window Toolkit(AWT) package. The Color class creates color by using the given RGBA values where RGBA stands for RED, GREEN, BLUE, ALPHA or using HSB value where HSB stands for HUE, SATURATION, BRIcomponents. The value for individual components RGBA ranges f 9 min read JavaFX | FontPosture Class FontPosture class is a part of JavaFX. FontPosture class specifies whether a font is REGULAR or ITALIC. FontPosture class inherits Enum class. Commonly Used Methods: Method Explanation findByName(String n) Returns FontPosture by its name. valueOf(String n) Returns a FontPosture with the specified na 2 min read JavaFX | CycleMethod Class CycleMethod class is a part of JavaFX. CycleMethod defines the method to use when painting outside the gradient bounds. It contains 3 Enum Constants as follows: NO_CYCLE: Used to define the cycle method which uses terminal colors to fill the remaining area. REFLECT: Used to define the cycle method w 6 min read JavaFX | ImagePattern Class ImagePattern is a part of JavaFX. This class is used to fills a shape with an image pattern. A user may specify the anchor rectangle, which defines the position, width, and height of the image relative to the upper left corner of the shape. If the shape extends out of the anchor rectangle, the image 4 min read Like