There was a feature like this, but it seems that it was talked about.
this feature would be very interesting in the TextField, and TextArea PasswordField.
Example: If max = 15, both the user input as the developer would be limited (truncated) to 15 characters.
In the textfield putting a method for filtering methods in this property (replaceText (int start, int end, String text) and ReplaceSelection (String text)).
This method would be something like:
private String checkMaxLen(String newString, int start, int end) {
if( getLenght() >= getMaxLenght()) return null;
int newLen = getLenght() + (end - start);
if(newLen <= getMaxLenght()) return newString;
String filteredNewString = newString.subString(0, getMaxLenght() - getLenght());
return filteredNewString;
}
Although version 2.1 is closed, I think it is something very simple, very helpful for everyone.
this feature would be very interesting in the TextField, and TextArea PasswordField.
Example: If max = 15, both the user input as the developer would be limited (truncated) to 15 characters.
In the textfield putting a method for filtering methods in this property (replaceText (int start, int end, String text) and ReplaceSelection (String text)).
This method would be something like:
private String checkMaxLen(String newString, int start, int end) {
if( getLenght() >= getMaxLenght()) return null;
int newLen = getLenght() + (end - start);
if(newLen <= getMaxLenght()) return newString;
String filteredNewString = newString.subString(0, getMaxLenght() - getLenght());
return filteredNewString;
}
Although version 2.1 is closed, I think it is something very simple, very helpful for everyone.
- duplicates
-
JDK-8101931 Add method to filter text added to a TextField
- Closed
-
JDK-8102198 Provide some utility properties on TextField/TextInputControl for restrictung user input
- Closed