This discussion is archived
1 Reply Latest reply: Oct 30, 2012 8:03 AM by Andipa RSS

Strange cursor behaviour when closing a sub-stage while mouse in TextField

Andipa Newbie
Currently Being Moderated
I have a substage that contains a text field. When I close the stage upon text field action (user hits Enter) and the mouse was inside the text field, the cursor remains in TEXT mode, even though the stage is closed.

Don't know whether I'm doing something awfully stupid or this is a javafx bug and I should file a bug report for it.

Here's a minimal example to reproduce it:

public class CursorBugTest extends Application {

    private void init(final Stage primaryStage) {
        Group root = new Group();
        primaryStage.setScene(new Scene(root, 600, 400));
        final Button button = new Button("Create a Stage");
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent t) {
                final Stage stage = new Stage();
                Group rootGroup = new Group();
                Scene scene = new Scene(rootGroup, 200, 200);

                final TextField textField = new TextField();
                textField.setOnAction(new EventHandler<ActionEvent>() {
                    public void handle(ActionEvent actionEvent) {
                        // if the substage is closed while the cursor is within the text field
                        // the cursor type is still TEXT in the primary stage

    @Override public void start(Stage primaryStage) throws Exception {

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


  • Correct Answers - 10 points
  • Helpful Answers - 5 points