Round Corners in java fx pane

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


If You Don't want to background Color the just 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. */

Finally after so much research and some help from the spanish version of Stack O. the most easy way to remove the white corners is this:

In the main class you must add:

scene.setFill(Color.TRANSPARENT);

and:

stage.initStyle(StageStyle.TRANSPARENT);

The only problem is that StageStyle.TRANSPARENT will leave you without the close button so you must make it by yourself. The final result is this:

enter image description here

Tags:

Css

Java

Javafx