Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090417

maxLength in Texts Controls

    XMLWordPrintable

    Details

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              gstiwesjfx giovanni stiwes (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Imported: