To reproduce run following code
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class TreeViewBorder extends Application {
public static void main(String[] args) {
launch(args);
}
private Parent getContent() {
VBox list = new VBox();
TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
TreeView tree = new TreeView(root);
tree.setFocusTraversable(false);
tree.setStyle("-fx-border-style: segments(5,10); -fx-border-color: red;");
// tree.maxHeight(50);
// tree.maxWidth(50);
list.getChildren().addAll(tree);
return list;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(getContent());
stage.setScene(scene);
stage.setVisible(true);
}
}
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class TreeViewBorder extends Application {
public static void main(String[] args) {
launch(args);
}
private Parent getContent() {
VBox list = new VBox();
TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
TreeView tree = new TreeView(root);
tree.setFocusTraversable(false);
tree.setStyle("-fx-border-style: segments(5,10); -fx-border-color: red;");
// tree.maxHeight(50);
// tree.maxWidth(50);
list.getChildren().addAll(tree);
return list;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(getContent());
stage.setScene(scene);
stage.setVisible(true);
}
}