GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes JTextArea disable scroll on select all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea disable scroll on select all" Watch "JTextArea disable scroll on select all" New topic
Author

JTextArea disable scroll on select all

Alvi Sait
Greenhorn

Joined: Jul 25, 2012
Posts: 2
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

Joined: May 03, 2008
Posts: 4571
    
    5

Hi, Alvi and welcome to the Ranch! Read the API for DefaultCaret, you should be able to find something useful there.


luck, db
There are no new questions, but there may be new answers.
Alvi Sait
Greenhorn

Joined: Jul 25, 2012
Posts: 2
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

Joined: May 03, 2008
Posts: 4571
    
    5

To get better help sooner, post a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4571
    
    5

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

Joined: May 03, 2008
Posts: 4571
    
    5

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.
 
GeeCON Prague 2014
 
subject: JTextArea disable scroll on select all