JDK-6866751 : J2SE_Swing_Reg: the caret disappears when moving to the end of the line.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.0,7,8,8u40
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp,windows_vista
  • CPU: x86
  • Submitted: 2009-07-30
  • Updated: 2015-06-16
  • Resolved: 2015-04-09
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.
JDK 9
9 b65Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
platform: VistaUltimate_64bit
build:1.7.0.b64
Case#: closed/javax/swing/text/DefaultCaret/4785160/bug4785160.java

# Case description:
Ensure that the horizontal scrollbar is visible in the JTextArea(or reduce the
with of applet so that the scrollbar becomes visible).Move the text caret in
the text area to the end of line. Test passed if the caret is visible at the
end of the line,failed if the caret disappears when moved to the end of the
line.

# Actual behavior:
The caret disappears when moved to the end of the line.
Attached is the screenshots
# Exceptions:
None
# Steps to reproduce:
1).do as the following code:
---------Begin code---------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
///manual=yesno

public class bug4785160 extends JApplet {
    JTextArea area = null;
    public void init() {
        super.init();
try {
        //get default lookandfeel
        System.out.println(UIManager.getLookAndFeel());
        //set nimbuslookandfeel---------------------------
       
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}catch (Exception ex1) {

}

        try {
            area = new JTextArea();
            getContentPane().add(new JScrollPane(area));
           
area.setText("mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
            area.getCaret().setDot(area.getText().length() + 1);
            area.requestFocus();
        } catch(Exception e) {
            System.out.println("Unexpected exception :");
            e.printStackTrace();
            throw new RuntimeException("Test failed.");
        }
    }
}
---------End code-----------
2).compile the code:${JDK7_HOME}/bin/javac bug4785160.java 
compile successfully.
3).run the class file:${JDK7_HOME}/bin/java   bug4785160
4).os default lookandfeel is MetalLookAndFeel,the case fail
5).set lookandfeel as Nimbus,please see the code's comment��the case pass.
#Validation
same issues happens to;
Product: j2se
OS: ubuntu9.04-i586
JDK/JREBuildNo.: 1.7.0b66
affects test
javax/swing/text/DefaultCaret/4785160/bug4785160.java

Comments
Cursor size is not taken into account when preferred width of a text component is calculated. If LnF set non-zero insets for the component it compensates the issue otherwise (System LaF) cursor is not seen. Solution : take into account the cursor width.
24-03-2015

It has the same issue on mac10.9-x64 with JDK8u40b10(64bit).
20-10-2014

You have approval to defer the following issues. Please update. Cheers, B.
07-10-2013

jdk8: SQE OK to defer
02-10-2013

8-defer-request; the issue from 1.0
01-10-2013

The sams issue on mac10.9-x64,jdk8b104(64bit) closed/javax/swing/text/GlyphView/4188841/bug4188841.java
12-09-2013

EVALUATION The caret is really invisible when it goes to the end of the line, this should be sorted out
19-05-2010