I'm trying to synchronize the scroll bars between 2 template canvases. I found a few relevant post and got to this point of experimenting however instead of setting the scroll bar position on my template canvas it sets the position of the scroll bar in the designer. When I run a client it sets nothing. It does the same thing if I change the object reference to: "event.source", "event.source.parent", "event.source.parent.parent". All work to set the designer scroll bar position.
Why is it not setting the object of interest?
from javax.swing import SwingUtilities
from javax.swing import JScrollPane
Once I get past this basic attempt to set the scroll position, I hope to further develop this to read the position of one template canvas and set the other to the same. The code will live in InternalFrameOpened so that is fires every time the scroll bar is moved similar to this post:
I tried to use a simplified version of the code in the post I linked because the objects are referenced differently but I get the error: "object has no attribute 'getVerticalScrollBar' when used on my template canvas. I then tried it on a table like the post and it worked. So can I not access the same properties of a template canvas? Is there another way to set the scroll bar position of a template canvas?
#singleColumnTable = event.source.parent.getComponent('Group 1').getComponent('Template Canvas 1') # doesn't work
singleColumnTable = event.source.parent.getComponent('Table') # this works!
scrollBarSingleColumn = singleColumnTable.getVerticalScrollBar()
scrollBarSingleColumn.setValue(200)