This discussion is archived
5 Replies Latest reply: Jan 28, 2013 10:14 AM by sselvia RSS

TableView horizontal and vertical scrolling is horribly slow

sselvia Newbie
Currently Being Moderated
How can I adjust the horizontal and vertical scrolling amount?

I used the Ensemble example prorgam and streched the column so that the horizontal scroll bar is displayed. I then used the right scroll button which then scrolls extremly slow. I've looked at the javadoc on the tableview and I cannot determine how to set the scrolling amount. I can check if the table is scrolling but I would like to set the amount to be a column width at a time when using the left or right arrow.
  • 1. Re: TableView horizontal and vertical scrolling is horribly slow
    sselvia Newbie
    Currently Being Moderated
    Any work arounds on this?
  • 2. Re: TableView horizontal and vertical scrolling is horribly slow
    James_D Guru
    Currently Being Moderated
    This is really ugly, and I hope someone can come up with something better, but you could try something like this:
    for (Node node : tableView.lookupAll(".scroll-bar")) {
      if (node instanceof ScrollBar) {
        ScrollBar scrollBar = (ScrollBar) node ;
        if (scrollBar.getOrientation() == Orientation.HORIZONTAL) {
          scrollBar.setUnitIncrement(...);
          scrollBar.setBlockIncrement(...);
        } else if (scrollBar.getOrientation() == Orientation.VERTICAL) {
          scrollBar.setUnitIncrement(...);
          scrollBar.setBlockIncrement(...);
        }
      }
    }
  • 3. Re: TableView horizontal and vertical scrolling is horribly slow
    sselvia Newbie
    Currently Being Moderated
    works great, the only thing I noticed...it does not see the lookup values ".scroll-bar" in the controller's initialize method, the columns had been added to the table view prior to the code previously posted. In my service/task code where I populate the rows into the table I used the code to set the scrollbar increments.
  • 4. Re: TableView horizontal and vertical scrolling is horribly slow
    James_D Guru
    Currently Being Moderated
    It probably needs to be actually rendered to the Scene graph before the lookups can be made, so the lookups won't work in the initialize method.

    There are a number of reasons I don't like this solution
    - I don't like the string binding
    - the fact that there are scrollbars that are descendant nodes of the table view is not documented, so (at least in theory) a future release of JavaFX could choose not to use the ScrollBar class (for example by creating its own scrolling implementation). This would break the code you have.
    - if you decided to create (or use) an alternative skin for the table view which had other scrollbars in place (again, unlikely but theoretically possible), you'd end up setting the unit and block increments of those scrollbars too. In other words, there's no guarantee these are the actual scrollbars you want.

    So, not ideal but at least if it works you have something...
  • 5. Re: TableView horizontal and vertical scrolling is horribly slow
    sselvia Newbie
    Currently Being Moderated
    trust me the duct tape and coat hanger is far better than what the tableview gives you now.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points