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

Non-editable JEditorPane displays caret

XMLWordPrintable

    • b04
    • 21
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      MacBook Pro 13-inch M2 2022. Sonoma 14.4

      openjdk 21.0.3 2024-04-16 LTS
      OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
      OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      When focus is gained on a JEditorPane with editable set to false, the caret is displayed.

      When focus is gained, DefaultCaret.focusGained is called, and subsequently DefaultCaret.setVisible(true) is called regardless if the component is editable or not.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JEditorPane and set editable = false

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Caret is not set to visible when the component is not editable.
      ACTUAL -
      When focus is gained, caret is made visible

      CUSTOMER SUBMITTED WORKAROUND :
      Add a focus listener onto the component and when focus is gained, set caret.visible = false

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: