treeviewjavafxscrollpane

Remove JavaFX TreeView Scroll Pane


I need to use a JavaFX 2.2 TreeView control inside a larger scrollpane that has several other elements which are not part of the Treeview. The problem is that TreeView has its own built-in scrollpane. Does anyone have an example of a way to turn off the built-in scrollpane so that the TreeView grows as large as the items contained within it?


Solution

  • While it is not currently possible to remove the scroll bars, it IS possible to mostly hide them with CSS.

    .your-selector *.column-header-background *.show-hide-columns-button,
    .your-selector *.scroll-bar:vertical *.increment-button,
    .your-selector *.scroll-bar:vertical *.decrement-button,
    .your-selector *.scroll-bar:vertical *.increment-arrow, 
    .your-selector *.scroll-bar:vertical *.decrement-arrow {
        -fx-background-color: null;
        -fx-background-radius: 0;
        -fx-background-insets: 0;
        -fx-padding: 0;
        -fx-shape: null;
    }
    
    .your-selector *.scroll-bar:horizontal,
    .your-selector *.scroll-bar:horizontal *.track,
    .your-selector *.scroll-bar:horizontal *.track-background,
    .your-selector *.scroll-bar:horizontal *.thumb,
    .your-selector *.scroll-bar:horizontal *.increment-button,
    .your-selector *.scroll-bar:horizontal *.decrement-button,
    .your-selector *.scroll-bar:horizontal *.increment-arrow, 
    .your-selector *.scroll-bar:horizontal *.decrement-arrow {
    	-fx-base: transparent;
    	-fx-background-color: white;
    }