JDK-8090341 : Add protected createTextField method to ComboBox and DatePicker
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-05-15
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
We have a requirement to provide a subclass of TextField for the ComboBox and DatePicker. Right now the editorProperty is read-only so we can't set it. If you can change new TextField() code in the editorProperty() method to createTextField() which is defined like this, it would be sufficient enough for us.

protected TextField createTextField() {
    return new TextField();
}
Comments
Re-opening the issue, since sub-classing ComboBox is not a (good) option for us.
21-05-2013

I decided to withdraw this feature request because I decided to extend ComboBoxBase directly so that I can have more customization, more than creating a custom text field.
20-05-2013

Unfortunately the validation checking has to be done on every keystroke and there are a lot of logic behind the validation, more than a callback can handle. I really think adding such a protected method to allow us to use our own text field is the easiest and safest thing to do.
16-05-2013

Copying the Eric's proposal, that really make sense since its avoid to subclass TextField, and moreover would be compatible with a future validation/formatter engine : "Couldn't we have a "vetoing callback" on TextInputControl ? For example : TextInputControl. setAcceptCallback(Callable<String, Boolean> callback) Callback would be passed the candidate new string ; application would check the candidate string and returns true if it accepts it ; TextInputControl could then accept or ignore the candidate string accordingly. This callback could also coexist with a future validation engine."
16-05-2013

Just revised the title and description to include DatePicker in addition to the ComboBox.
15-05-2013

Yes. I did a super cool FormattedTextField/MaskTextField ;-)
15-05-2013

We have a similar requirement to check the input text characters/format. David, do you need to subclass TextField for the same thing ?
15-05-2013

Any feature must be test, and its behavior must be specified.
15-05-2013

It doesn't seem to me that the addition of this method would affect anything, or raise the need of adding an extra test case.
15-05-2013

Ok, could you add test, that check, that editable/noneditable switching, etc, don't make this method call.
15-05-2013

That is not the intent - the createTextField method would be called on instantiation of a ComboBox, and just once. Once the ComboBox is instantiated the TextField will not be able to be changed.
15-05-2013

Just a question, how often this method will be called? I mean, if I want to replace an existing text field, having changed a logic inside this method, how to force to update the text field?
15-05-2013