简体   繁体   中英

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 ... )

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM