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

Win: Cursor remains in text style when closing a sub-stage while mouse is in TextField

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 7u9
    • javafx
    • Windows 7 32-bit

      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 style, even though the stage is closed.

      Here's a minimal example to reproduce it:

      {code}
      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);
                      stage.setScene(scene);
                      stage.centerOnScreen();
                      stage.show();
       
                      final TextField textField = new TextField();
                      textField.setOnAction(new EventHandler<ActionEvent>() {
                          @Override
                          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
                              button.setText(textField.getText());
                              stage.close();
                          }
                      });
                      rootGroup.getChildren().add(textField);
                  }
              });
              root.getChildren().add(button);
          }
       
          @Override
          public void start(Stage primaryStage) throws Exception {
              init(primaryStage);
              primaryStage.show();
          }
       
          public static void main(String[] args) { launch(args); }
      }
      {code}

            anthony Anthony Petrov (Inactive)
            apabstjfx Andreas Pabst (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: