JavaFX Rectangle set fill color
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; import javafx.stage.Stage; public class Main extends Application { @Override//from w w w .j a v a 2 s .c o m public void start(Stage primaryStage) { // Create a group and add nodes to the group Group group = new Group(); for (int i = 0; i < 4; i++) { Rectangle r = new Rectangle(100, 50, 100, 30); r.setRotate(i * 360 / 8); r.setStroke(Color.color(Math.random(), Math.random(), Math.random())); r.setFill(Color.WHITE); group.getChildren().add(r); } Scene scene = new Scene(new BorderPane(group), 250, 150); primaryStage.setTitle("ShowRectangle"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }