In as much as CSS is considered public API, please review https://javafx-jira.kenai.com/browse/RT-38192, which allows FXML to be specified as the -fx-graphic property of Labeled.

Example of a Button with a graphicProperty that is specified in CSS as a Region shaped like an X:

    @Override
    public void start(Stage stage) {

        Button button = new Button("Button");
        Scene scene = new Scene(new StackPane(button), 200, 200);
        scene.getStylesheets().add("/fxtest/test.css");
        stage.setScene(scene);
        stage.show();

    }

/* test.css */
.button {
-fx-graphic: url("fxml:,<?import javafx.scene.layout.Region?><Region styleClass=\"graphic\"/>");
}
.button > .graphic {
-fx-shape: "M2,0 L5,4 L8,0 L10,0 L10,2 L6,5 L10,8 L10,10 L8,10 L5,6 L2,10 L0,10 L0,8 L4,5 L0,2 L0,0 Z";
    -fx-background-color: red;
    -fx-min-width: 10;
    -fx-min-height: 10;
}

Reply via email to