2 Replies Latest reply: Feb 7, 2013 9:43 PM by krbltik RSS

    TreeView scrollbar

    krbltik
      I wonder is there any solution to disable TreeView's scrollbar by API or css?
        • 1. Re: TreeView scrollbar
          shakir.gusaroff
          Hi. Try this:

             
                  final Node scrollBar = tree.lookup(".scroll-bar:vertical");
                  scrollBar.setDisable(true);
          Example:
          import javafx.application.Application;
          import javafx.scene.Node;
          import javafx.scene.Scene;
          import javafx.scene.control.TreeItem;
          import javafx.scene.control.TreeView;
          import javafx.scene.image.Image;
          import javafx.scene.image.ImageView;
          import javafx.scene.layout.StackPane;
          import javafx.stage.Stage;
           
          public class TrSample extends Application {
          
               public static void main(String[] args) {
                  launch(args);
              }
              
              @Override
              public void start(Stage primaryStage) {
                  primaryStage.setTitle("Tree View Sample");        
                  
                  TreeItem<String> rootItem = new TreeItem<String> ("Inbox");
                  rootItem.setExpanded(true);
                  for (int i = 1; i < 106; i++) {
                      TreeItem<String> item = new TreeItem<String> ("Message" + i);            
                      rootItem.getChildren().add(item);
                  }        
                  TreeView<String> tree = new TreeView<String> (rootItem);        
                  StackPane root = new StackPane();
                  root.getChildren().add(tree);
                  primaryStage.setScene(new Scene(root, 300, 250));
                  primaryStage.show();
                  
                  final Node scrollBar = tree.lookup(".scroll-bar:vertical");
                  scrollBar.setDisable(true);
                 
                  
                  
                  
                  
              }
          }
          • 2. Re: TreeView scrollbar
            krbltik
            Thanks a lot! And what about removing scrollbar completely? I need to drag visible part of TreeView by mouse inside a container.