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

[TextField] prompt text is not applied immediately

XMLWordPrintable

      Run code:


      package javafx_text_prompt;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class JavaFX_Text_Prompt extends Application{

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              
              VBox vb = new VBox();
              
              final TextField testedTextField = new TextField();
              HBox hb = new HBox();
              
              final TextField tf1 = new TextField();
              Button apply = new Button("Set prompt text");
              apply.setOnAction(new EventHandler<ActionEvent>(){
                  @Override
                  public void handle(ActionEvent t) {
                      testedTextField.setPromptText(tf1.getText());
                  }
              });
              
              hb.getChildren().addAll(tf1, apply);
              
              TextField tf2 = new TextField();
              tf2.textProperty().bindBidirectional(testedTextField.promptTextProperty());
              
              vb.getChildren().addAll(new Label("Prompt text issue"), testedTextField, hb, new Label("Current prompt text: "), tf2);
              
              Scene scene = new Scene(vb, 300, 300);
              stage.setScene(scene);
              stage.show();
          }
      }


      Using the second textField (with pressing button) or the third textField, which's text is bidirectionally binded to PromptText of the first textField, I try to set promptText using different manipulation and I couldn't for a long time (see attached movie).

      You can see, that property is set properly, but it is not rendered.

      This issue affects on comboBox(editable), passwordField.

            leifs Leif Samuelsson (Inactive)
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: