TitledPane background color

Peter Penzov peter.penzov at gmail.com
Thu Dec 25 23:13:30 UTC 2014


Hi All,
   I have a question how to change TitledPane background color. I tested
this code:

public class MainApp extends Application {

    @Override
    public void start(Stage stage) throws Exception {

        TitledPane pane = new TitledPane("Title", null);
        pane.setStyle("-fx-focus-color: transparent; -fx-background-color:
green;");
        pane.setCollapsible(false);
        pane.setPrefSize(300, 500);


        Scene scene = new Scene(pane);

        stage.setTitle("JavaFX and Maven");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

I tried to set the background color to green but when I run the code the
background color is gray. What is the proper way to change the background
color of the TitledPane body?

BR,
Peter


More information about the openjfx-dev mailing list