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

TextArea's caret doesn't update on font change until clicked by mouse.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b08
    • Introduced In Version:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      openjdk 11.0.2 2018-10-16
      OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)

      javafx.version=11.0.2
      javafx.runtime.version=11.0.2+1
      javafx.runtime.build=1

      A DESCRIPTION OF THE PROBLEM :
      If a TextArea has its font changed the caret will not resize or relocate. This leaves the caret out-of-place until the user clicks somewhere on the TextArea.

      TextField does not appear to have the same issue.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a TextArea with some text in it.
      2. Change the Font of the TextArea (preferably with significant size difference).
      3. If necessary, refocus the TextArea (don't click on TextArea) to display caret.
      4. View incorrect caret.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The caret updates automatically to reflect the new text size and position.
      ACTUAL -
      The caret does not update until the user clicks on the TextArea.

      ---------- BEGIN SOURCE ----------
      import javafx.animation.PauseTransition;
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TextArea;
      import javafx.scene.text.Font;
      import javafx.stage.Stage;
      import javafx.util.Duration;

      public class App extends Application {

        @Override
        public void start(Stage primaryStage) {
          var area = new TextArea("Hello, World!");
          area.positionCaret(3); // to make it easier to see

          var delay = new PauseTransition(Duration.seconds(1.0));
          delay.setOnFinished(e -> area.setFont(Font.font("System", 72.0)));

          primaryStage.setScene(new Scene(area));
          primaryStage.show();

          area.requestFocus();
          delay.play();
        }
        
        public static void main(String[] args) {
          launch(App.class, args);
        }

      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: