bog
bog

Reputation: 1333

JavaFX - How can I fill with color a shape?

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)

Upvotes: 6

Views: 57735

Answers (1)

jewelsea
jewelsea

Reputation: 159576

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));

Upvotes: 17

Related Questions