JDK-4174856 : Custom caret is not redrawn in JTextPane
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1998-09-18
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.2.0Fixed 1.2.2 1.2.2Fixed
Related Reports
Relates :  
Description
When customized caret is set by setCaret(), it registers its
DocumentListener for position update. Then, that DocumentListener is called
*before* the listener for the views(e.g.
BasicTextUI$UpdateHandler.insertUpdate()). So when the
DefaultCaret.insertUpdate() is called, there can be a mismatch between the
model structure and view structure. This causes modelToView return null
rectangle and DefaultCaret.damage() will not cause repaint(). The default
order of DocumentListeners is that the listener for the views is first, and
the listener for the caret is next. So this problem does not happen.

I attached a sample program to reproduce this problem. To reproduce,

1) Compile the sourc
2) Run at the command shell as 'java CaretTest'
3) When the window appears, click the JTextPane
4) Input some characters(other than 's')
5) Then input "s", this will install customized caret.
6) Type any character, you will see the caret is drawn incorrectly.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2.2 1.2fcs INTEGRATED IN: 1.2.2 1.2fcs swing1.1
14-06-2004

EVALUATION The repaint request for the new caret position is queued on the event queue to guarantee that things have stabilized and order of DocmentEvent delivery won't effect the update. timothy.prinzing@eng 1998-09-25
25-09-1998