Details

    • Type: Sub-task
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: fx2.0
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
      None

      Description

      This is a minimal test case for RT-17772 as requested by Leif.

      Sorry for creating a subtask, but I don't have the ability to comment on a jira I didn't create, and I already had this test case lying around for the same issue.
      Original issue was posted to forum => https://forums.oracle.com/forums/thread.jspa?threadID=2305905&tstart=0
      Workaround for issue is to use Platform.runLater to set the text field, so you can see what I think giovanni is trying to achieve.
      Enter a string starting with the letter g is permitted by the test case. Entering a string starting with any other value (should) set the text to empty.

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
       
      public class TextFieldResetTest extends Application {
        public static void main(String[] args) { Application.launch(args); }
        @Override public void start(Stage primaryStage) {
          final TextField t = new TextField();
          t.textProperty().addListener(new ChangeListener<String>() {
            @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
              if (!newValue.startsWith("g") && !"".equals(newValue))
                t.setText("");
                // Platform.runLater(new Runnable() { public void run() { t.setText(""); } });
            }
          });

          VBox root = new VBox();
          root.getChildren().addAll(t);
          primaryStage.setScene(new Scene(root, 300, 100));
          primaryStage.show();
        }
      }

        Attachments

          Activity

            People

            Assignee:
            leifs Leif Samuelsson (Inactive)
            Reporter:
            josmithjfx John Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: