JDK-8090453 : Provide some useful TextInputControl.Formatter implementations
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u40
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2014-07-02
  • 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
Blocks :  
Duplicate :  
Duplicate :  
Description
After RT-14000 is fixed, we should add some basic Formatter implementations to cover the most common cases.

Some ideas:
* A formatter (or just a StringConverter) that uses toString and valueOf methods (or constructor) - similar to DefaultFormatter in swing. 
* A formatter that uses java.text.Format or StringConverter
* Predefined formatters for currency, date, numbers (?) - we have Format instances for that, but can we make it more convenient than that?
* javax.swing.text.MaskFormatter equivalent.
* Regexp formatter or only a filter
Comments
From https://bugs.openjdk.java.net/browse/JDK-8132331: It is a rather common request from application users that they want an application to not allow "unwanted" or "unparseable" characters to be entered into text input controls. For example, a TextField bound to an integer should not accept letters. While TextFormatter is available since 8u40 and provides a basic solution to that, it is a real pain to configure, particularly in FXML-driven projects. It would be great if a future release of JavaFX would provide predefined, locale-bound TextFormatter instances which can be referenced from FXML. Example: <TextField textFormatter="$INTEGER_FORMATTER" /> <TextField textFormatter="$DECIMAL_FORMATTER" />
28-07-2015

RT-38630 might contain more requirements.
11-09-2014

I talked to Kevin about this and we believe that it is sufficient to provide example code for 8u40.
27-08-2014

From openjfx-dev post: * StringFormatter for converting between String and arbitrary object using toString and valueOf (or String constructor), which would do similar job as DefaultFormatter in swing. * MaskFormatter (similar to the class of the same name in swing) - it would support String mask, defining own placeholder character, escape character or even defining own map (as a Map<Character, UnaryOperator<Character>>), where the unary operator for the map either returns null (if not accepted) or the same/modified character if accepted. * A TextFormatter that takes java.text.Format and does the filtering and converting using the Format object.
19-08-2014