Reputation: 3432
I have TreeView placed as content of ScrollPane. ScrollPane is placed inside SplitPane. When I drag divider of SplitPane so that it becomes bigger than TreeView size I see border of TreeView. I want TreeView to be resized as much as space is available after I drag divider of SplitPane. My code:
SplitPane splitPane = new SplitPane();
splitPane.getItems().addAll(createTreeOfConnections());
private ScrollPane createTreeOfConnections() {
ScrollPane scrollPane = new ScrollPane();
scrollPane.setMinSize(100, 300);
scrollPane.setPrefSize(200, 500);
scrollPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setContent(new ConnectionsTree(this));
return scrollPane;
Class ConnectionsTree extends TreeView and its constructor is :
public ConnectionsTree(MainStage mainStage) {
// here we set the root of ConnectionsTree which is not visible
super();
this.mainStage = mainStage;
root = new ConnectionTreeItem();
root.setExpanded(true);
super.setRoot(root);
super.setShowRoot(false);
super.setEditable(false);
super.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
super.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
retrieveExistentConnectionsNodes();
ContextMenu contextMenu = new ContextMenu(createNewConnectionMenuItem(
"New Connection", KeyCombination.valueOf("Ctrl+N")));
super.setContextMenu(contextMenu); }
How to tell TreeView(my TreeConnections) that it should take all available space of left part of SplitPane?
Thank you!
Upvotes: 1
Views: 3309
Reputation: 49185
Try this
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
Upvotes: 2