JavaFX样式是通过使用CSS完成的。
.button{
-fx-border-color: transparent;
-fx-border-width: 0;
-fx-background-radius: 0;
-fx-background-color: transparent;
-fx-font-family:"Segoe UI", Helvetica, Arial, sans-serif;
-fx-font-size: 1em; /* 12 */
-fx-text-fill: #828282;
}
.button:focused {
-fx-border-color: transparent, black;
-fx-border-width: 1, 1;
-fx-border-style: solid, segments(1, 2);
-fx-border-radius: 0, 0;
-fx-border-insets: 1 1 1 1, 0;
}
.button:pressed {
-fx-background-color: black;
-fx-text-fill: white;
}
将此代码添加到CSS文件中,将其保存到控件的源文件所在的目录中,其中包含您的按钮。然后在这个类中:
getStylesheets().add(getClass().getResource("nameofyourcssfile.css").toExternalForm());
然后,该对象包含的所有按钮都将使用此样式类。
对您需求的修改很简单。