I cannot find an answer about this anywhere on the internet.
I have an application that has to have collapsable panels, so the TitledPane and Accordion set-up in Java FX is a natural candidate.
In the application, I need to have custom headers for the container when it's collapsed. I see in the css document for the TitledPane that the header is really an HBox and a variety of other components.
http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#titledpane
I would like to access this component and replace it with a custom component.
I have been using the TitledPane api's setGraphic function and setContentDisplay to GraphicOnly. with a custom component. However, I cannot get it to render correctly. I've had issues with removing the arrow, and removing the space occupied by the arrow.
See the link below for screenshots of the desired look and how it actually looks.
How does one remove the arrow and remove the padding?
In the present day at the end of 2018 nothing of these solutions works with JavaFX of JDK 1.8. So I've working on a simple solution. You can copy this method in and utility class:
TitledPane is a Labeled, so you can set a graphic on it in a listener or a binding to the expanded property.
Changing background colors etc (including overriding styling of the :focused pseudo-class) is something that can be accomplished via css (refer to the TitledPane section of the caspian.css stylesheet in jfxrt.jar for examples).
If you need code based access to sub-components of the TitledPane, you can use the lookup function after the TitledPane has been added to a Scene shown on a Stage.
I'd advise trying the graphic/css stylesheet based approaches before trying a lookup.
If you don't need the Labeled to display text then set it display a graphic only.
Here is some sample code which displays a TitledPane with a customized header next to a TitledPane without a customized header.
And some css to go with it:
(Moved answer from question)
This is the answer:
To remove the arrow, add this CSS declaration:
The above CSS snippet will remove the arrow, but the space for the arrow is still occupied. This was really tricky and I couldn't find it documented anywhere on the internet, but I applied this CSS statement and it removed the gap from the arrow.
This may not be the best solution, but it is a solution that has worked for my needs.
This is how you remove the arrow: