I am working on a JavaFx Application in which I need a list of Tree Views. This is an application solving problem , every time I create a new problem a new tree view is created.
I want to maintain a list of such tree views which is feasible to scroll.
What I tried?
1.)Create a scroll pane and put a vbox in it.
2.)Add tree views in a vbox.
Issues with this
When I resize the window the vbox does not resize.(While putting any container inside scroll pane I cannot set Fit To Parent From Scene Builder)
Please suggest a good way to implement list of tree views
MyCode
@FXML
private VBox treeContainer;
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
for(int j=0;j<3;++j){
TreeItem<String> rootItem = new TreeItem<String> ("Item " + j);
rootItem.setExpanded(true);
String[] names = {"SubItem1","SubItem2", "SubItem3","SubItem4", "SubItem5","SubItem6","SubItem7",};
for (int i = 0; i < names.length; i++) {
TreeItem<String> item = new TreeItem<String> (names[i]);
rootItem.getChildren().add(item);
}
TreeView<String> tree = new TreeView<String> (rootItem);
tree.setMaxHeight(Double.MAX_VALUE);
tree.setStyle("-fx-background-color: white");
treeContainer.getChildren().add(tree);
}
}