문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top