Round corners in java fx pane

I am trying to get around the bottom corners in my application, but the result is the following:

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 to remove these white corners?

+8
source share
3 answers

Finally, after so much research and some help from the Spanish version of Stack O. the easiest way to remove white corners:

In the main class, you should add:

scene.setFill(Color.TRANSPARENT);

and

stage.initStyle(StageStyle.TRANSPARENT);

The only problem is that it StageStyle.TRANSPARENTwill leave you without a close button, so you have to do it yourself. The end result is as follows:

enter image description here

+4
source

If you do not want to use the background color, try this: -fx-background-color: transparent;

OR

-fx-background-size: 1200 900;
-fx-background-radius: 30;
-fx-border-radius: 30;
-fx-border-width:5;
-fx-border-color: #FC3D44;

OR

 -fx-background-size: 1200 900;
 -fx-border-radius: 10 10 0 0;
 -fx-background-radius: 10 10 0 0;
 -fx-border-color: #FC3D44;

  /* top-left, top-right, bottom-right, and bottom-left corners, in that order. */
+5
source

, Css:

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

You should put this code in your main class:

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

I found this from this source

0
source

All Articles