• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable Caret in a Document

 
Mike DeStefano
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Craig Wood
Ranch Hand
Posts: 1535
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
textArea.getCaret().setVisible(false);
 
Matti Poro
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can still use the arrow keys to scroll the text area after setting the caret invisible.

JTextArea.setFocusable(false);
 
Mike DeStefano
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic