To reproduce run following code
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Callback;
/**
*
* @author javafx
*/
public class Test1 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
private Parent getContent() {
Pane pane = new HBox();
TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
root.setExpanded(true);
TreeItem<String> firstBrunch = new TreeItem<String>("brunch 1");
firstBrunch.setExpanded(true);
firstBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
root.getChildren().addAll(firstBrunch);
TreeItem<String> secondBrunch = new TreeItem<String>("brunch 2");
secondBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
root.getChildren().addAll(secondBrunch);
TreeView tree = new TreeView(root);
tree.setFocusTraversable(false);
tree.setMaxSize(130,140);
pane.getChildren().add(tree);
return pane;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(700);
stage.setHeight(700);
Scene scene = new Scene(getContent());
stage.setScene(scene);
stage.show();
}
}
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Callback;
/**
*
* @author javafx
*/
public class Test1 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
private Parent getContent() {
Pane pane = new HBox();
TreeItem<String> root = new TreeItem<String>("ROOT", new Rectangle(20, 20, Color.CHOCOLATE));
root.setExpanded(true);
TreeItem<String> firstBrunch = new TreeItem<String>("brunch 1");
firstBrunch.setExpanded(true);
firstBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
root.getChildren().addAll(firstBrunch);
TreeItem<String> secondBrunch = new TreeItem<String>("brunch 2");
secondBrunch.getChildren().addAll(new TreeItem<String>("first item"), new TreeItem<String>("second item", new Rectangle(20, 20, Color.DARKGREY)));
root.getChildren().addAll(secondBrunch);
TreeView tree = new TreeView(root);
tree.setFocusTraversable(false);
tree.setMaxSize(130,140);
pane.getChildren().add(tree);
return pane;
}
public void start(Stage stage) {
stage.setX(100);
stage.setY(100);
stage.setWidth(700);
stage.setHeight(700);
Scene scene = new Scene(getContent());
stage.setScene(scene);
stage.show();
}
}