File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disable Caret in a Document
 
Similar Threads
obtaining mouse pointer position within a document
Columns vs letters
Displaying a "floating" JLabel
select a row inJTextArea using CaretPosition
how to auto scroll to see the bottom of the jtextarea?