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

TextField with unexpected behavior in textProperty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.1
    • fx2.0
    • javafx

      Add a listener in textProperty, when there is a change in text, verify if the same is valid, if invalid set empty in text.

      see:

      textProperty().addListener(new ChangeListener<String>() {
          private boolean inProgress;
          @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
              if (inProgress) {
                  return;
              }
              inProgress = true;
              try {
                  thow new Exception(); //here logic code for validation
              } catch (ParseException e) {
                  setText("");
              }
              inProgress = false;
          }
      });


      In the case above the TextField should be always empty.

      But it's not what happens. Always gets a letter.

            mheinrichs Michael Heinrichs (Inactive)
            gstiwesjfx giovanni stiwes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: