DrHell
DrHell

Reputation: 481

How to scrolldown a Container to some precise coordinate

Simplifying, I have this structure

Form {
   tab=Container(BoxLayout.y());
   other stuff
}

The Form is not scrollable (and it is not supposed to be), tab is.

At some point I want to redraw the Form to keep it up to date with some new info added, and I do that creating a new one and showing it.

But I want to scroll down the Container tab to its predecessor's Y-coordinate.

I can easily save the Y coordinate in a static variable using

scrolledToY=tab.getScrollY();

But I can't find a way to set it back when I create the new form.

setScrollY seems to be protected, and indeed if I try to run the program using it, I get an error

error: setScrollY(int) has protected access in Component tab.setScrollY(scrolledToY);

What is the correct function to use, instead? Thanks.

Upvotes: 0

Views: 35

Answers (1)

Shai Almog
Shai Almog

Reputation: 52760

You can use scrollRectToVisible().

FYI you can just modify the container and call revalidate to update the UI. This will prevent a nasty refresh problem you might experience. Also check out InfiniteContainer which might be what you're really looking for.

Upvotes: 1

Related Questions