How do I add two images, one above the other to a shape in JavaFX?

Multi tool use


How do I add two images, one above the other to a shape in JavaFX?
Please help.
I am trying to add two images to the shape:
@FXML
private Rectangle rectangle;
Image img1 = new Image("a.png");
Image img2 = new Image("b.png");
rectangle.setFill(new ImagePattern(img1));
rectangle.setFill(new ImagePattern(img2));
These images have a transparent background. Both should be visible. One above the other.
But only one is visible.
I will be grateful for the advice.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.