Is there a way in JavaFx (CSS) to get the same effect like when using -fx-background-radius: 20;
for background images?
My test project looks like this:
The Main.css-file:
.root {
-fx-background-image: url("space.png");
-fx-padding: 50;
}
.hBox {
-fx-background-image: url("background.jpg");
-fx-background-radius: 10;
-fx-padding: 0;
/*-fx-shape:"M0 13,C0 5, 5 0, 13 0, L105 0, C113 0, 118 5, 118 13, L118 65, C118 73, 113 78, 105 78, L13 78, C5 78, 0 73, 0 65Z";*/
}
The Java Code:
public class Start extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
VBox vBox = new VBox();
HBox hBox = new HBox();
hBox.setPrefHeight(100);
hBox.setPrefWidth(100);
hBox.getStyleClass().add("hBox");
vBox.getChildren().add(hBox);
hBox.getChildren().add(new Label("Hallo"));
Scene scene = new Scene(vBox, 1000, 800, false, SceneAntialiasing.BALANCED);
scene.getStylesheets().add(Start.class.getResource("Main.css").toExternalForm());
primaryStage.setTitle("Test");
primaryStage.setScene(scene);
primaryStage.setHeight(200);
primaryStage.setWidth(200);
primaryStage.show();
}
}
But the result looks like this: