Re: Showing text cursor in JTextPane



IchBin wrote:
Jim Rootham wrote:

What has to be true for a text cursor to show in a JTextPane?

I have a dynamic set of JTextPanes that may or may not have focus. Sometimes when they have focus the text cursor does not display. What do I need to do to force it to display?

Thanks

Jim Rootham

Do you have text in JTextPanes?

Could the cursor be sitting at the end of the text in the JTextPanes?

If you mean by dynamic that you insert the text then maybe the cursor is at the end of the inserted text. This would not be visible.

Override DefaultCaret.adjustVisibility() to do nothing.

or

set caret position: setCaretPosition(int position)


Sometimes there is text there, sometimes not. The cursor will show at the end of text. I do want the caret not to show if the JTextPane does not have focus.

I can't find setCaretPosition as part of JTextPane.

I am calling setSelectionStart and setSelectionEnd when the JTextPane gets the focus. I am calling KeyboardFocusManager.clearGlobalFocusOwner to remove the text cursor after I disable editing when another part of the panel is sits on is clicked.

Jim Rootham
.



Relevant Pages

  • Re: Showing text cursor in JTextPane
    ... Jim Rootham wrote: ... I have a dynamic set of JTextPanes that may or may not have focus. ... Could the cursor be sitting at the end of the text in the JTextPanes? ...
    (comp.lang.java.gui)
  • Showing text cursor in JTextPane
    ... What has to be true for a text cursor to show in a JTextPane? ... I have a dynamic set of JTextPanes that may or may not have focus. ... Sometimes when they have focus the text cursor does not display. ...
    (comp.lang.java.gui)