• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea disable scroll on select all

 
Alvi Sait
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every time I select all (Ctrl+A) text on a text area, it scrolls to the bottom.

Is there anyway to maintain the position or the visible rectangle while still selecting all the contents?
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Alvi and welcome to the Ranch! Read the API for DefaultCaret, you should be able to find something useful there.
 
Alvi Sait
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Hi, Alvi and welcome to the Ranch! Read the API for DefaultCaret, you should be able to find something useful there.


Hi, Actually I've tried



but still the textarea scrolls down upon select all.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or maybe you're satisfied with the answers in your cross post, and don't intend to return to this. That's not how I would have done it though.

In future, please BeForthrightWhenCrossPostingToOtherSites.
http://stackoverflow.com/questions/11646678/jtextarea-disable-scroll-on-select-all
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for completeness, since it appears that the cross poster won't be back, this is how I would have done it, by replacing the select all action for the text area.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic