Hi all. I'm having a problem with a round border and a round background. If you look at the code below you will see that I have a border specified with a radius of 5. If I run this, the background sticks outside of the border. If I also set the background to have a radius of 5, it still doesn't look correct as the outside of the border turns purple whereas I would expect it to be light red. If I change the background radius to 4 then the inside of the border doesn't quite match up to the background.
How do I set a border and just say the background should be "clipped" by it?
Thanks, Nick.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
public class RoundTest extends Application {
@Override
public void start(Stage stage) throws Exception {
FlowPane flowPane = new FlowPane();
Scene scene = new Scene(flowPane, 500, 500);
flowPane.setStyle("-fx-padding: 10;");
Label label = new Label("Hello");
label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue;");
// label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue; -fx-background-radius: 5;");
flowPane.getChildren().add(label);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}