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 rect =
new
Rectangle(x, y, w, h);
rect.setFill(Color.WHITE);
rect.setStrokeWidth(
1
);
rect.setStroke(Color.BLACK);
Button button =
new
Button(
"Click To See the Effects!"
);
button.setLayoutX(
100
);
button.setLayoutY(
30
);
button.setPrefSize(
250
,
150
);
button.setOnAction(
new
EventHandler<ActionEvent>() {
public
void
handle(ActionEvent event)
{
ColorInput colorInput =
new
ColorInput(x, y,
w, h, Color.STEELBLUE);
button.setEffect(colorInput);
}
});
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();
}
public
static
void
main(String args[])
{
launch(args);
}
}