Java clicked/focus 时 FX 按钮略小
Java FX buttons slightly smaller when clicked/focus
我有一个问题,我的 JavaFX 按钮在单击时变得略小。
here可以看到"change password"按钮是clicked/selected.
here 你可以看到 "admin functions" 按钮是 clicked/selected.
我怀疑这与具有焦点的按钮有关,因为当我单击 chrome 或具有此 运行 的其他应用程序时,它会恢复到所需的 look
按钮当前位于 4x1 GridPane 中,第 0 个槽被标签占用。
这是我的 CSS 如果有帮助的话:
.button{
-fx-border-color: null;
-fx-border-width: 0;
-fx-background-color: #2c3cff;
-fx-fill: true;
-fx-pref-height: 100;
-fx-pref-width: 320;
-fx-text-fill: #b9b9b9;
-fx-border-radius: 0;
-fx-min-width: 320;
-fx-min-height: 100;
-fx-background-radius: 0;
-fx-animated: false;
}
.grid{
-fx-background-color:#3e3e48;
}
.label{
-fx-text-fill: #b9b9b9;
}
Edit: I have found a temporary "solution", more of a workaround: I put
a horizontal separator just below my HBox and this allowed me to mask
the weird button size changes. would still like answers about how to
do this properly.
Thanks!
所以,经过长时间尝试使用分隔符等变通方法后,我想通了。
默认的 FX 样式表将此应用于所有按钮:
-fx-background-insets: 0 0 -1 0, 0, 1, 2;
虽然在我的 .button:focused
定义中我将它们设置为 0,但在我的 .button
定义中我没有,所以它从默认值 CSS 中获取了插入值。通过将 -fx-background-insets: 0,0,0,0,0;
应用于 .button
和 .button:hover
我能够达到预期的结果。
Note: you can just type -fx-background-insets: 0;
i left the full values in in case i want to change at a later date.
我有一个问题,我的 JavaFX 按钮在单击时变得略小。
here可以看到"change password"按钮是clicked/selected.
here 你可以看到 "admin functions" 按钮是 clicked/selected.
我怀疑这与具有焦点的按钮有关,因为当我单击 chrome 或具有此 运行 的其他应用程序时,它会恢复到所需的 look
按钮当前位于 4x1 GridPane 中,第 0 个槽被标签占用。
这是我的 CSS 如果有帮助的话:
.button{
-fx-border-color: null;
-fx-border-width: 0;
-fx-background-color: #2c3cff;
-fx-fill: true;
-fx-pref-height: 100;
-fx-pref-width: 320;
-fx-text-fill: #b9b9b9;
-fx-border-radius: 0;
-fx-min-width: 320;
-fx-min-height: 100;
-fx-background-radius: 0;
-fx-animated: false;
}
.grid{
-fx-background-color:#3e3e48;
}
.label{
-fx-text-fill: #b9b9b9;
}
Edit: I have found a temporary "solution", more of a workaround: I put a horizontal separator just below my HBox and this allowed me to mask the weird button size changes. would still like answers about how to do this properly.
Thanks!
所以,经过长时间尝试使用分隔符等变通方法后,我想通了。
默认的 FX 样式表将此应用于所有按钮:
-fx-background-insets: 0 0 -1 0, 0, 1, 2;
虽然在我的 .button:focused
定义中我将它们设置为 0,但在我的 .button
定义中我没有,所以它从默认值 CSS 中获取了插入值。通过将 -fx-background-insets: 0,0,0,0,0;
应用于 .button
和 .button:hover
我能够达到预期的结果。
Note: you can just type
-fx-background-insets: 0;
i left the full values in in case i want to change at a later date.