Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the rounded corners from JavaFX buttons

Tags:

css

javafx

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.

like image 903
ki81 Avatar asked Jan 02 '23 10:01

ki81


1 Answers

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

like image 99
Mazen Embaby Avatar answered Jan 16 '23 05:01

Mazen Embaby