Question

is it possible to completely remove the title of a TitledPane?

I managed to make it invisible using the following code in the css-file:

.titled-pane > .title{
    -fx-background-color: rgba(0, 100, 0, 0.0);
    -fx-font-size: 0;
}

But it still takes up space, and when I hover over it with my mouse, the cursor changes. Changing the padding didn't help either.

Basically, I only need the expandable / collapsable abilities of the TitledPane, which are executed when a Button is pressed.

Was it helpful?

Solution

According to the TitledPane's Substructure, the title is a HBox. So we can lookup it and hide then:

Platform.runLater(new Runnable() {
    @Override
    public void run() {
        Pane title = (Pane) titledPane.lookup(".title");
        if (title != null) {
            title.setVisible(false);
        }
    }
});

It should be run in Platform.runLater(...) after the scene constructed and rendered.

OTHER TIPS

A bit old, but you could do this by CSS as well. Given your titledPane has id filterTitledPane, you could have :

#filterTitledPane .title {
    -fx-pref-height: 1;
}

#filterTitledPane .title .text {
    visibility: false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top