Short answer: there is no API for changing the duration.
However, there are two ways to achieve this:
Alternative # 1: Reflection
Duration is defined in the static final field com.sun.javafx.scene.control.TitledPaneSkin.TRANSITION_DURATION . Using reflection, you can change its value , but it is really bad. . Not only because it is a dirty hack, but also because TitledPaneSkin is an Oracle internal API that can be changed . In addition, this does not fix the problem with different speeds:
private static void setTitledPaneDuration(Duration duration) throws NoSuchFieldException, IllegalAccessException { Field durationField = TitledPaneSkin.class.getField("TRANSITION_DURATION"); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(durationField, durationField.getModifiers() & ~Modifier.FINAL); durationField.setAccessible(true); durationField.set(TitledPaneSkin.class, duration); }
Alternative number 2: set your own skin
To be safe, you can create and use your own skin (start by copying an existing one) using titledPane.setSkin() . This way you can also fix different speeds, which is mainly caused by linear or simple interpolation, but this is pretty good job.
source share