aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Disable Caret in a Document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Disable Caret in a Document" Watch "Disable Caret in a Document" New topic
Author

Disable Caret in a Document

Mike DeStefano
Ranch Hand

Joined: May 24, 2002
Posts: 36
I have an uneditable JTextArea embedded within a JScrollPane. Is there any way to remove the caret in the JTextArea document so that UP and DOWN don't move the document.

Thanks in advance..


-Mike Destefano<br />"Sometimes you feel like a nut..."
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
textArea.getCaret().setVisible(false);
Matti Poro
Ranch Hand

Joined: Dec 03, 2005
Posts: 41
You can still use the arrow keys to scroll the text area after setting the caret invisible.

JTextArea.setFocusable(false);
Mike DeStefano
Ranch Hand

Joined: May 24, 2002
Posts: 36
OMG!!! It worked!!! Praise Zeus and the Java Gods! To think disabling scrolling on UP and DOWN keyboard events was that easy! GGGGEEEEEEZZZZ!!!

Thanks very much!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Disable Caret in a Document