Automatic horizontal scroll on javafx TableView

140 Views Asked by At

If I scroll on my table to the right it will automatically scroll back to the left. I have no own implementation for scrolling, all is done by the TableView. Has anyone seen this before? If I test it on windows I have no issue.

compile "org.javafxports:jfxdvk:8.60.13"
javafxportsVersion = '8.60.13'
1

There are 1 best solutions below

0
mapicke On

This issue is more related to javafx. If the "IS_TOUCH_SUPPORTED" flag is set the scroll bar is set to visible false after use (VirtualFlow). A change listener onVisible does then a updateHbar(). And because of hbar.isVisible() the scroll var value is set to 0. I did not want to change "IS_TOUCH_SUPPORTED". That's why I create a own skin which only creates a custom virtual flow. The custom virtual flow is also very simple I only set the tempVisibility to true via reflection. And I also overwrite the startSBReleasedAnimation() method and do nothing inside.

public class CustomVirtualFlow<T extends IndexedCell<?>> extends VirtualFlow<T> {

public CustomVirtualFlow() {
    super();

    try {
        final Field field = VirtualFlow.class.getDeclaredField("tempVisibility");             
        field.setAccessible(true);

        field.setBoolean(this, true);
    } catch (final Exception e) {       
    }
}

/*
 * (non-Javadoc)
 *
 * @see com.sun.javafx.scene.control.skin.VirtualFlow#startSBReleasedAnimation()
 */
@Override
protected void startSBReleasedAnimation() {
    // do not call the super.startSBReleasedAnimation()
}