JDK-7119745 : Unable to view focus in Non-Editable TextArea
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86
  • Submitted: 2011-12-09
  • Updated: 2012-03-20
  • Resolved: 2011-12-21
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
Ijava version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux  2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :

When the TextArea instance is set to non-editable, it does not show a caret when it is focused. This will confuse users.

There is a bug reported to JTextArea for many years.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run the testcase with jdk7.
2. Press tab to move the focus to TextArea


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A caret is showing to indicate it has the focus.
ACTUAL -
No caret is showing.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.TextArea;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class OJDK103 {

    public static void main(String[] str) {
        JFrame jf = new JFrame();
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton jb = new JButton("click");
        JPanel jp = new JPanel();
        jf.setSize(200, 200);
        JTextArea jt = new JTextArea(3, 3);
        jf.getContentPane().add(jp);
        jp.add(jb);
        jp.add(jt);
        jf.setVisible(true);
        jt.setText("hello how r u");
        jt.setEditable(false);
        TextArea ta = new TextArea(6, 10);
        ta.setText("Rajesh kumar");
        ta.setEditable(false);
        jp.add(ta);
    }

}
---------- END SOURCE ----------

Comments
EVALUATION The description of the bug is very confusing since it is referring to TextArea, but has the following statement "There is a bug reported to JTextArea for many years." TextArea and JTextArea are very different terms since the first is referring to AWT library when the second is about Swing. I guess that it is about Swing JTextArea and close this bug as not a defect, since uneditable JTextArea is not focusable at all and so it is impossible to view the focus in this component.
21-12-2011

EVALUATION Seems like a Swing issue.
19-12-2011