How to bind vertical scroll in multi tableview

Hi javafx folks,

Today I will show how to make your multi table view bind with a single ScrollBar. JavaFX is becoming more and more powerful and nowadays people are using this javafx for comaparing the data between tables and it’s pretty much helpful for scrolling the tables with a single Scrollbar.

To make this things happen ; Firstly I have dived to check if there is any api for making scroll binding in both tables but I didn’t find them. I then went to see if there is any manual scroll of the tableview finally i found them scrollTo(int) which is really helpful for the programmer to scroll the tableview manually.

Lets first see how we are going to make this happen.

Table Vertical Scrolling Binding

 

As you can see in the above picture I’ve stated how to make two tableview vertical Scroll bind with a single External ScrollBar.

Firstly You need to hide your vertical scrollbar.  Please add styleclass “mytableview” for both of the table view to make this css to take effect.

 

Hiding Vertical Scrollbar of TableView from CSS

As I’ve already stated here i’ve used “mytableview” class which is the TableView class.

Now Just create Two TableView and one ScrollBar Let’s suppose “table1”, “table2” and “scroller”.
Let’s see how it works

Scroll TableView with ScrollBar value

Now you have sucessfully made multi-tableview scroll from a single ScrollBar.

Only this much for today.
Have a 🙂 good day. Keep on coding with technique.

 
 

Demo


7 thoughts on “How to bind vertical scroll in multi tableview”

  1. I’m getting this trying to see the demo:

    Plug-in 10.9.2.05
    JRE 1.7.0_09-b05 Java HotSpot(TM) 64-Bit Server VM

    java.security.AccessControlException: access denied (“java.lang.RuntimePermission” “accessDeclaredMembers”)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
    at java.security.AccessController.checkPermission(AccessController.java:560)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1679)
    at java.lang.Class.checkMemberAccess(Class.java:2174)
    at java.lang.Class.getDeclaredFields(Class.java:1759)
    at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
    at javafx.fxml.FXMLLoader.access$1400(FXMLLoader.java:68)
    at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:655)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:572)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2742)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2721)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2707)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2694)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2683)
    at javafxapplication2.JavaFXApplication2.start(JavaFXApplication2.java:22)

  2. pozycjonowanie stron lublin

    Everyone loves what you guys are up too. This type
    of clever work and exposure! Keep up the amazing works guys
    I’ve incorporated you guys to our blogroll.

  3. Thanks …
    But i have some question .
    is There a way to access the rows viewed in current view of table view
    with out using scroll to method
    i need to get number of row that is showing .
    Thanks

Leave a Reply