Scroll scrollbar to position via script

Got it!

RC = system.gui.getParentWindow(event).rootContainer
me = RC.getComponent('Template Repeater')

#Get the scrollPane object which contains the viewPort object by finding it
components = me.getComponents()
for component in components:
	if str(type(component)) == "<type 'com.jidesoft.swing.JideScrollPane'>":
		scrollPane = component

viewport = scrollPane.getViewport()

#Get the 'visible rectangle' which basically defines the current view of the full scroll-able pane
rect = viewport.getVisibleRect()
#Add '400' units to the horizontal scroll position
rect.y = rect.y + 400

#write the new visible rectangle back to the scroll-able object
viewport.scrollRectToVisible(rect)

Thanks for your prompt, Sander

Edit: I replaced the static scrollPane component assignment with a loop to find this component instead, so this should work for any component now and not just the template repeater

1 Like