> Hi,
>
> I have a JTextPane (or JTextComponent) which works fine. When I call
> setEditable(false), the caret is not visible. How can I make the caret
> visible on
> not editable JTextPane?
*Why* do you (think you) need to give the end user
a caret in a non-editable text area?
Since the caret indicates the place that has the *input*
focus, and there is no input for a non editable component,
it does not make that much sense. (And would be confusing).
Note that in this example, the text *selection* shows clearly,
that is probably all the user needs.
</sscce>
import java.awt.*;
import javax.swing.*;
public class CaretInText extends JPanel {
CaretInText() {
setLayout( new BorderLayout() );
JTextPane tp = new JTextPane();
tp.replaceSelection("Hi There!");
tp.setCaretPosition(0);
tp.moveCaretPosition(3);
tp.setEditable(false);
add( tp, BorderLayout.CENTER );
}
public static void main(String[] args) {
JFrame f = new JFrame("Caret In Text");
f.getContentPane().add( new CaretInText() );
f.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
f.pack();
f.setVisible(true);
}
}
</sscce>
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
ndrli@yahoo.com - 23 Jun 2005 16:58 GMT
Why? The user can search dwon/up from the caret. If the caret is not
visible,
It is not clear from which positon to start your search.
> *Why* do you (think you) need to give the end user
> a caret in a non-editable text area?
[quoted text clipped - 42 lines]
> http://www.1point1C.org/ Science & Technology
> http://www.LensEscapes.com/ Images that escape the mundane
Andrew Thompson - 23 Jun 2005 17:08 GMT
> Why?
Why what? Please place comments after the text to which
you are replying, and trim any stuff to which you are
not replying.
>..The user can search dwon/up from the caret. If the caret is not
> visible,
> It is not clear from which positon to start your search.
Try offering the search from 'start of selected text'(?).

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane