Best Link for JavaFX CSS Properties and Selectors

I am trying to learn JavaFX 2, but I stumbled a lot about styling my application. I found this document that is trying to document the controls and css properties that apply to them. I can’t say if it is incomplete, if I have to use some unknown selector or JavaFX CSS support, just not enough for my needs.

Here are some examples:

  • How to change the background color for the area behind the TabPane without coloring every other child component (is there a selector for this, or perhaps a property?)
  • How to change color of not selected tabs?
+5
source share
2 answers

- ?

, "Skinning JavaFX Applications with CSS". "#MyTabPane" TabPane. (, .tab .tab-content-area . "caspian.css", jfxrt.jar, .)

TabExample.css

#MyTabPane .tab {
    -fx-background-color: blue;
}
#MyTabPane .tab:selected {
    -fx-background-color: red;
}

#MyTabPane .tab-content-area {
    -fx-background-color: cyan;
}

#MyTabPane .tab *.tab-label {
    -fx-text-fill: white;
}

TabPaneEx.java

@Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World");
        StackPane root = new StackPane();
        TabPane pane = new TabPane();
        pane.setId(("MyTabPane"));
        Tab tab1 = new Tab("ONE");
        Tab tab2 = new Tab("TWO");
        Tab tab3 = new Tab("THREE");
        pane.getTabs().addAll(tab1,tab2,tab3);
        Scene scene = new Scene(root, 300, 250);
        root.getChildren().add(pane);
        scene.getStylesheets().add(
                this.getClass().getClassLoader().getResource("tabpaneex/TabExample.css").toString());
        primaryStage.setScene(scene);
        primaryStage.show();
    }
+10

All Articles