This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable Caret in a Document

 
Mike DeStefano
Ranch Hand
Posts: 36
  • 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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
textArea.getCaret().setVisible(false);
 
Matti Poro
Ranch Hand
Posts: 41
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic