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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.