JavaFX + CSS
EDIT
Przykład:
/*
* FILE UseOfCSSInJavaFx.java
*/
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class UseOfCSSInJavaFx extends Application {
public Parent createContent() {
/* layout */
BorderPane layout = new BorderPane();
/* layout -> center */
VBox vBox = new VBox(10);
/* layout -> center -> buttons */
String stylesheet = UseOfCSSInJavaFx.class.getResource("StylesheetForButtons.css").toExternalForm();
Button button_1 = new Button("Google...");
button_1.setId("button_1");
button_1.getStylesheets().add(stylesheet);
Button button_2 = new Button("...prawdę...");
button_2.setId("button_2");
button_2.getStylesheets().add(stylesheet);
Button button_3 = new Button("...Ci powie.");
button_3.setId("button_3");
button_3.getStylesheets().add(stylesheet);
/* layout -> center (add items) */
vBox.getChildren().addAll(button_1, button_2, button_3);
vBox.setAlignment(Pos.CENTER);
/* return layout */
layout.setCenter(vBox);
return layout;
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent()));
stage.setWidth(200);
stage.setHeight(200);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
/*
* FILE StylesheetForButtons.css
*/
#button_1 {
-fx-background-color:
#090a0c,
linear-gradient(#38424b 0%, #1f2429 20%, #191d22 100%),
linear-gradient(#20262b, #191d22),
radial-gradient(center 50% 0%, radius 100%, rgba(114,131,148,0.9), rgba(255,255,255,0));
-fx-background-radius: 5,4,3,5;
-fx-background-insets: 0,1,2,0;
-fx-text-fill: white;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
-fx-font-family: "Arial";
-fx-text-fill: linear-gradient(white, #d0d0d0);
-fx-font-size: 12px;
-fx-padding: 10 20 10 20;
}
#button_2 {
-fx-background-color:
#3c7fb1,
linear-gradient(#fafdfe, #e8f5fc),
linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
-fx-background-insets: 0,1,2;
-fx-background-radius: 3,2,1;
-fx-padding: 3 30 3 30;
-fx-text-fill: black;
-fx-font-size: 14px;
}
#button_3 {
-fx-background-color:
linear-gradient(#ffd65b, #e68400),
linear-gradient(#ffef84, #f2ba44),
linear-gradient(#ffea6a, #efaa22),
linear-gradient(#ffe657 0%, #f8c202 50%, #eea10b 100%),
linear-gradient(from 0% 0% to 15% 50%, rgba(255,255,255,0.9), rgba(255,255,255,0));
-fx-background-radius: 30;
-fx-background-insets: 0,1,2,3,0;
-fx-text-fill: #654b00;
-fx-font-weight: bold;
-fx-font-size: 14px;
-fx-padding: 10 20 10 20;
}
Źródło: http://fxexperience.com/2011/12/styling-fx-buttons-with-css/