JavaFX - How can I fill with color a shape?


Question

Let's say that I have an application window and I declare Circle c = new Circle(40,40,40);, which is initially black. What should I do if I want to fill it with red?

What should I do if I want to fill it with red? (for example, if a button is clicked, then c becomes red)

1
5
6/25/2016 2:41:14 PM

Set a fill on the shape (Java 8 code):

Circle circle = new Circle(40, 40, 40); 
Button button = new Button("Red");
button.setOnAction(e -> circle.setFill(javafx.scene.paint.Color.RED));
11
4/11/2018 1:23:53 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon