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

Non-editable JTextArea displays cursor postion at the end

XMLWordPrintable

    • b01
    • 20
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Microsoft Windows [Version 10.0.19045.2965]

      openjdk version "21-ea" 2023-09-19
      OpenJDK Runtime Environment (build 21-ea+24-2086)
      OpenJDK 64-Bit Server VM (build 21-ea+24-2086, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      A non-editable JTextArea component displays a cursor at the end.

      REGRESSION : Last worked in version 17.0.7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the provided reproducer.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A non-editable JTextArea should not display a caret.
      ACTUAL -
      Non-editable JTextArea displays caret. This error also occurs with Java 20.0.1.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class CaretBugFrame extends JFrame
      {
         public CaretBugFrame()
         {
            super( "Caret Bug" );
            setDefaultCloseOperation( EXIT_ON_CLOSE );

            JTextArea textArea = new JTextArea( 6, 25 );
            textArea.setEditable( false );
            textArea.setLineWrap( true );
            textArea.setWrapStyleWord( true );
            textArea.setText( "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." );
            add( textArea );
            
            pack();
            setVisible( true );
         }

         public static void main( String[] args )
         {
            EventQueue.invokeLater( () -> { new CaretBugFrame(); } );
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Stay on Java 17

      FREQUENCY : always


            kizune Alexander Zuev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: