• Post Reply Bookmark Topic Watch Topic
  • New Topic

suppress scrolling  RSS feed

 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code I'm working on creates a JScrollPane that wraps a JTextPane. A customer has requested the ability to pause scrolling when the user drags the knob in the vertical scrollbar off the bottom (i.e. when they scroll back in the text--this is a chat app). The goal is to allow them to view portions of text or even copy it without it scrolling off the new screen as chat is inserted asynchronously. When they drag the knob down to the bottom again, scrolling should be reactivated. Yahoo chat works this way.

I can track whether or not the knob is off the bottom by reacting to an adjustmentValueChanged event and doing a bit of arithmetic with the scroll bar's current value. The question is, how do I actually suspend the scrolling? I experimented with scrollRectToVisible but haven't been able to get anything to work yet.

Any suggestions and/or code are greatly appreciated.

thanks,
Jeff
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know about a textPane, but in a textArea, repositioning the caret stops
the scrolling.

if it workd the same way in a textpane, all you'll need to do is get the
viewport to show where the scrollbar was on mouseReleased

 
Jeff Langr
author
Ranch Hand
Posts: 799
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Michael. I'll take a more detailed look. You can set the caret position, as far as I can see.

-J-
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!