-
Bug
-
Resolution: Duplicate
-
P4
-
fx2.1
-
2.1.0b10
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.
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.
- duplicates
-
JDK-8114961 TextField with promptText and initial text value does not show promptText when initial text is deleted
- Resolved