Getting scroll bar position

Hi All, is there a way to get scroll bar position in a tab panel? I need to refresh the interface using the new solutionModel function and I don’t want the user to lose it’s place in the software.

Not that I know but maybe you could focus the right element (field, label, etc) to go to the desired vertical position, have a look at the elements.xx.requestFocus().

Or maybe there is another way to accomplish what you want, without the need of rebuilding the form using the Solutionmodel?

Can you explain the problem a little bit more?

I won’t go into detail, but I’m using servoy solutionModel to generate a dynamic interface with unlimited attributes and language… which can’t be done any other way.

So it’s not possible to place a tab pane to it’s original position after refreshing it??

Not in javascript but maybe it’s doable with a couple of java code lines. Sorry but I don’t know how to help you on this.

on element level, there is a function: getScrollPosition (out of my head)
don’t know if this applies to tabpanels…

maybe have a look at: JComponent.getVisibleRect() and JComponent.scrollRectToVisible() from java

Can we have access to the jcomponnent java sublevel of servoy componnent??

yes, that is possible and was presented at Servoy World 2008. Have a look at: http://forum.servoy.com/viewtopic.php?f=27&t=11170 . The idea is to rewrap the object as NativeJavaObject.

lvostinar:
yes, that is possible and was presented at Servoy World 2008. Have a look at: viewtopic.php?f=27&t=11170 . The idea is to rewrap the object as NativeJavaObject.

Success!! Thanks Ivostinar!

I succeded in using a method similar to the one proposed in your pdf.

//Get the name of the button that was pushed to refresh the tabPane
var element_name = application.getMethodTriggerElementName();

//gets the button itself
var button = forms.product_attribute.elements[element_name];

//gets the JPanel that displays the scroll bars
var panel = Packages.javax.swing.SwingUtilities.getAncestorOfClass(Packages.javax.swing.JPanel, button);

//gets the displayed rectangle coordinate
var rect = panel.getVisibleRect();

//this sets the y coordinate of the displayed rectangle to 250 px
rect.y=250;
	
//this feed the new rect to the JPanel
panel.scrollRectToVisible(rect)

Thanks A lot, it’s not easy to use the component. It seems that servoy wrap every component that contains “JS_” method. This wrapper keeps servoy from working with the non “JS_” methods… including geParent().

So by using “Packages.javax.swing.SwingUtilities.getAncestorOfClass(Packages.javax.swing.JPanel, button);” it allows servoy to get a true JPanel that is not wrapped and therefor can be work with just like in Java.

Thanks again!