JDK-8333846 : Non-editable JEditorPane displays caret
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 21,22,23
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2024-05-16
  • Updated: 2024-06-10
  • Resolved: 2024-06-10
Related Reports
Relates :  
Description
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



Comments
This change was made intentionally by JDK-4512626 ( JDK-8299077 ).
10-06-2024

The observations on Windows 11: JDK 21ea+3: Passed. JDK 21ea+4: Failed. JDK 22: Failed. JDK 23ea+14: Failed.
09-06-2024

Requested a complete reproducer from the submitter.
03-06-2024