GOXR3PLUS
GOXR3PLUS

Reputation: 7265

Change JavaFX TableView Vertical ScrollBar value programmatically

Description:

Let's assume that we have a simple JavaFX TableView, and it has 50 items. I want to scroll vertically at 0.49.

You can use the example from Oracle Tutorial (https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/table-view.htm )


So i am using:

ScrollBar verticalBar = (ScrollBar) tableViewer.lookup(".scrollbar:vertical");
verticalBar.setValue(0.49);

But it doesn't work....


I can't find a way to work around with this . The .scrollTo(...)->link doesn't give that precision . I need the vertical bar to be exactly at (0.49 or 0.24 or ... )

Upvotes: 1

Views: 2908

Answers (1)

Dth
Dth

Reputation: 1976

It seems you have a typo, a scrollbar instead of scroll-bar. This is a correct line:

ScrollBar verticalBar = (ScrollBar) tableViewer.lookup(".scroll-bar:vertical");

Upvotes: 1

Related Questions