You can see that problem in attached movie (in the bottom - output of invalidation listener about currently selected range).
Steps to reproduce: minimize application window to taskbar and open back. Note, whether selection changing or not.
import javafx.application.Application;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class HelloTextField extends Application {
private Group content;
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(content = new Group(), 500, 500));
stage.centerOnScreen();
stage.show();
final TextField label = new TextField();
label.setPromptText("Enter Pithy Pun");
label.setText("bbbbbbbbbbbbbbbbbbbbb");
label.selectionProperty().addListener(new InvalidationListener() {
public void invalidated(Observable o) {
System.out.println(label.getSelection());
}
});
label.selectAll();
content.getChildren().add(label);
//label.setText("aaa");
}
public static void main(String[] args) {
Application.launch(HelloTextField.class, args);
}
}
Steps to reproduce: minimize application window to taskbar and open back. Note, whether selection changing or not.
import javafx.application.Application;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
public class HelloTextField extends Application {
private Group content;
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(content = new Group(), 500, 500));
stage.centerOnScreen();
stage.show();
final TextField label = new TextField();
label.setPromptText("Enter Pithy Pun");
label.setText("bbbbbbbbbbbbbbbbbbbbb");
label.selectionProperty().addListener(new InvalidationListener() {
public void invalidated(Observable o) {
System.out.println(label.getSelection());
}
});
label.selectAll();
content.getChildren().add(label);
//label.setText("aaa");
}
public static void main(String[] args) {
Application.launch(HelloTextField.class, args);
}
}
- relates to
-
JDK-8128758 [TextField] selection is not applied immidiately.
- Resolved
-
JDK-8116975 [TextField] Mouse selection goes away when another JavaFX window is clicked
- Closed