List of usage examples for javafx.scene.control TreeView setCellFactory
public final void setCellFactory(Callback<TreeView<T>, TreeCell<T>> value)
From source file:Main.java
@Override public void start(Stage primaryStage) { CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("A"); rootItem.setExpanded(true);// w ww . jav a2s.co m TreeView tree = new TreeView(rootItem); tree.setEditable(true); tree.setCellFactory(CheckBoxTreeCell.forTreeView()); CheckBoxTreeItem<String> checkBoxTreeItem = new CheckBoxTreeItem<>("a"); rootItem.getChildren().add(checkBoxTreeItem); checkBoxTreeItem = new CheckBoxTreeItem<>("b"); rootItem.getChildren().add(checkBoxTreeItem); tree.setRoot(rootItem); StackPane root = new StackPane(); root.getChildren().add(tree); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);//from www. j av a 2s. c om for (Employee employee : employees) { TreeItem<String> empLeaf = new TreeItem<>(employee.getName()); boolean found = false; for (TreeItem<String> depNode : rootNode.getChildren()) { if (depNode.getValue().contentEquals(employee.getDepartment())) { depNode.getChildren().add(empLeaf); found = true; break; } } if (!found) { TreeItem<String> depNode = new TreeItem<>(employee.getDepartment()); rootNode.getChildren().add(depNode); depNode.getChildren().add(empLeaf); } } stage.setTitle("Tree View Sample"); VBox box = new VBox(); final Scene scene = new Scene(box, 400, 300); scene.setFill(Color.LIGHTGRAY); TreeView<String> treeView = new TreeView<>(rootNode); treeView.setEditable(true); treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl()); box.getChildren().add(treeView); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);//from ww w. ja v a 2s . co m for (Employee employee : employees) { TreeItem<String> empLeaf = new TreeItem<>(employee.getName()); boolean found = false; for (TreeItem<String> depNode : rootNode.getChildren()) { if (depNode.getValue().contentEquals(employee.getDepartment())) { depNode.getChildren().add(empLeaf); found = true; break; } } if (!found) { TreeItem depNode = new TreeItem(employee.getDepartment()); rootNode.getChildren().add(depNode); depNode.getChildren().add(empLeaf); } } stage.setTitle("Tree View Sample"); VBox box = new VBox(); final Scene scene = new Scene(box, 400, 300); scene.setFill(Color.LIGHTGRAY); TreeView<String> treeView = new TreeView<>(rootNode); treeView.setEditable(true); treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl()); box.getChildren().add(treeView); stage.setScene(scene); stage.show(); }
From source file:net.rptools.tokentool.controller.TokenTool_Controller.java
private void addPseudoClassToLeafs(TreeView<Path> tree) { PseudoClass leaf = PseudoClass.getPseudoClass("leaf"); tree.setCellFactory(tv -> { TreeCell<Path> cell = new TreeCell<>(); cell.itemProperty().addListener((obs, oldValue, newValue) -> { if (newValue == null) { cell.setText(""); cell.setGraphic(null);//w w w . j a va 2 s. c o m } else { cell.setText(newValue.toFile().getName()); cell.setGraphic(cell.getTreeItem().getGraphic()); } }); cell.treeItemProperty().addListener((obs, oldTreeItem, newTreeItem) -> cell .pseudoClassStateChanged(leaf, newTreeItem != null && newTreeItem.isLeaf())); return cell; }); }
From source file:utilitybasedfx.MainGUIController.java
private CheckBoxTreeItem<String> preSetupOpsTree(TreeView tree) { CheckBoxTreeItem<String> root = new CheckBoxTreeItem("root"); root.setExpanded(true);/*from w ww. j a v a 2 s .c o m*/ tree.setStyle("-fx-font-size: 11; "); //tree.getStylesheets().add("/css/treeViewColouredSelection.css"); // [FIXME] make the color change! WHY IT NO WORK tree.setRoot(root); tree.setShowRoot(false); tree.setCellFactory(CheckBoxTreeCell.<String>forTreeView()); return root; }