Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Srolling of JScrollBar without user involvement

 
Sriram Sankar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application which i have put it on the jscrollpane, the problem is once i reach the bottom of the visible area in my application , i need my jscrollpane to scroll upwards automaticaly so that i need not every time manually scroll down to enter next set of data or view next set of data.
My requirement is to scroll the JScrollPane with code rrather that user involvement.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sriram,
I point you to 2 items:
JScrollPane --> getVerticalScrollBar (getHorizontalScrollBar)
JScrollBar --> setValue
Regards,
Manfred.
 
Chris Robertson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying something similar and am in fact using the setValue method, it seems to work but then teh scroll pane just bounces back down to the bottom. Sort of frustrating. (ok very frustrating.)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the scrollRectToVisible( Rectangle ) method of JComponent on the component inside the scrollpane rather than trying to move the scrollpane programmatically through the scroll bar...
 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is a gravedigg, but I have the same problem as described here. I have allready tested the solutions mentioned here, though and neither of them work.
To be more specific of the problem: I add text to the beginning of a JScrollPane. At one point, the scrollbar gets fixed at somewhat bellow middle, and I can`t seem to nod it up to the top by calling some legitimate methods (as mentioned here).

Please, I need some help from some swing dirty hands.
[ November 26, 2006: Message edited by: Haakon Lind ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have a textComponent in the scroll bar, the scroll will follow the caret,
so, when adding some text, include
textComponent.setCaretPosition(0);
 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Michael Dunn:
if you have a textComponent in the scroll bar, the scroll will follow the caret,
so, when adding some text, include
textComponent.setCaretPosition(0);


Great, this worked perfectly!
I`m used to getting a notification for answers, so I`m glad I checked back.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic