ki81
ki81

Reputation: 95

How to remove the rounded corners from JavaFX buttons

I've noticed that buttons in JavaFX have rounded corners, which means when you have a grid of them there are little white spaces visible between.

This illustrates the problem

I'd like to make my buttons appear as rectangles, with right angled corners, is this possible? I assume this might be possible with CSS, but I can't find this question being asked before.

Thanks.

Upvotes: 5

Views: 8180

Answers (1)

Mazen Embaby
Mazen Embaby

Reputation: 1361

You can do Via CSS :

"-fx-background-radius: 0"

You can add your CSS file in several ways by code , by Inline , External file

By Code :

Button rectangleButton = new Button();
roundButton.setStyle("-fx-background-radius: 0");

By FXML Inline :

enter image description here

By FXML External :

mystyle.css file

.button{
-fx-background-radius: 0;
}

then choose directory of file to apply the style to your container

enter image description here

Upvotes: 11

Related Questions