-fx-background-radius and -fx-background-insets in JavaFX

早过忘川 提交于 2020-06-11 11:18:10

问题


I am working with JavaFX and I want to customize a button. I saw several characteristics that can be styled. Among them I found two that are unknown to me.

.button {
    -fx-padding: 5 22 5 22;   
    -fx-border-color: #121212;
    -fx-border-width: 2;
    -fx-border-radius: 5;
    -fx-background-radius: 0;
    -fx-background-color: #555555;
    -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    -fx-font-size: 11pt;
    -fx-text-fill: #d8d8d8;
    -fx-background-insets: 0 0 0 0, 0, 1, 2;
}

what are these two properties:

-fx-background-insets: 0 0 0 0, 0, 1, 2; 

and

 -fx-background-radius: 0;

I saw this, but it is very vague for me.


回答1:


These 2 properties are documented in the linked document, but I'd prefer using the latest version: JavaFX CSS Reference: Region

Those 2 properties are used to create the background of the Button; they are used as the constuctor parameters for the BackgroundFill constructors (4 BackgroundFills will be used for the background since 0 0 0 0, 0, 1, 2 contains 4 sets of insets).

-fx-background-insets

This specifies the distance from the Button's bounds where the background should be drawn. E.g. if you have a button positioned at x=50, y=150, width=200, height=100 and use insets 10 20 30 40 the region used for the background is x=50+40=90, y=150+10=160, width=200-20-40=140, height=100-10-30=60.

-fx-background-radius

The background is drawn as a rounded rectangle. This is the radius of the corners. In this case 0 means the bachground will be drawn as a non-rounded rectangle.



来源:https://stackoverflow.com/questions/42465850/fx-background-radius-and-fx-background-insets-in-javafx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!