Making TextFields.setupClearButtonField(..) public, so SceneBuilder-injected CustomTextFields could be enhanced

Issue #330 new
Markus Seebauer
created an issue


I imported your controls into the Scene Builder and was able to layout various CustomTextField instances. In the according controller class @FXML-annotations were added and the CustomTextFields got injected.

I you would make the TextFields.setupClearButtonField public, one could 'enhance' the injected CustomTextFields in the controller's initialize method and the textfields would become clearable.

Using version 8.0.6 i was able to achieve this by calling the existing setupClearButtonField method by reflection:

private void setupClearButtonField(CustomTextField customTextField)  throws Exception {
            Method m = TextFields.class.getDeclaredMethod("setupClearButtonField", TextField.class, ObjectProperty.class);
            m.invoke(null, customTextField, customTextField.rightProperty());

kr max

Comments (5)

  1. IsNull_

    I agree that the current TextField API is very limited in its use. It is impossible to use with FXML. I too would prefer an API where you can pass in a CustomTextField Instance as parameter and get the given Instance decorated.

    I ended up copy & pasting the TextFields-Code and use my own implementation for it.

  2. tobiasdiez

    A public setupClearButtonField would also be very helpful when one wants to add a clear button to a custom text field control, which derives from CustomTextField.

  3. Log in to comment