Make Rectangle transparent

Stéphane GROSSMANN picture Stéphane GROSSMANN · Oct 6, 2014 · Viewed 12.3k times · Source

I need to make a drawn rectangle mouse transparent, in order to see the desktop. The following code draws my rectangle. What should I add to get that ? Thanks for help

public void start(Stage primaryStage) {
    Group group = new Group();

    Rectangle rect = new Rectangle(20,20,200,200);

    rect.setArcHeight(15);
    rect.setArcWidth(15);

    rect.setStroke(Color.BLACK);
    group.getChildren().add(rect);

    Scene scene = new Scene(group, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.show();
}

Answer

James_D picture James_D · Oct 6, 2014

If you just want the interior of the rectangle to be transparent, then all you need is

rect.setFill(Color.TRANSPARENT);

but I'm not quite sure if this is what you mean.