focus property in composed control

Tom Eugelink tbee at
Mon Feb 23 08:03:20 UTC 2015

JFXtras has a number of extended textfields (BigDecimal, Calendar, LocalDate, ...). These controls use a TextField in their skin to compose this control. These extended textfield controls have a readonly focusProperty()... What would be the best way to forward the focusProperty of the TextField to the control's focusProperty?
- Binding is not possible, because it is read only.
- Setting the value in the skin is not possible, because it is read only.
- setFocused method is protected final

What works is the following setup:
- create a _public_ focusForwardProperty in the Skin
- listen to the focusProperty of TextField and set the focusForwardProperty accordingly
- listen to the skinProperty in the Control and when set, bind a listener to the focusForwardProperty
- in this  listener call setFocused with the value of focusForwardProperty

This approach at least prevents the control's API to be polluted with public methods, but requires a property just for the sake of publishing the value. Ideally one would like to bind both focusProperties.


More information about the openjfx-dev mailing list