Round Corners in java fx pane

Viewed 20726

I'm trying to get round bottom corners in my application, but the result is this:

enter image description here

This is the CSS file:

.mainFxmlClass {
  #pane{
    -fx-background-size: 1200 900;
    -fx-background-radius: 0 0 18 18;
    -fx-border-radius: 0 0 18 18;
    -fx-background-color: #FC3D44;
  }
}

And my main class:

@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("Preview.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}
public static void main(String[] args) {
    launch(args);
}

How can I remove these white corners?

3 Answers

But if you want to have a picture for background instead of a solid color while you put the background in Css:

-fx-background-image: url("backs/background.jpg");

you should put such code in your Main class:

Rectangle rect = new Rectangle(1024,768);
rect.setArcHeight(60.0);
rect.setArcWidth(60.0);
root.setClip(rect);

I found it here

Related