List of usage examples for javafx.scene.control TreeView TreeView
public TreeView(TreeItem<T> root)
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Sample"); stage.setWidth(300);//from w ww .j ava2 s. c om stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); TreeItem<File> root = createNode(new File("/")); TreeView treeView = new TreeView<File>(root); vbox.getChildren().add(treeView); vbox.setSpacing(10); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
public BrowseEndpoint(Stage stage) { this.stage = stage; stage.setTitle("BioAssay Schema Browser"); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true);/* w w w . java 2 s . c o m*/ treeView.setCellFactory(p -> new BrowseTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldval, newval) -> { changeValue(newval.getValue()); }); display = new DisplaySchema(); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(display); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); Scene scene = new Scene(root, 700, 600, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item new Thread(() -> backgroundLoadTemplates()).start(); }
From source file:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);//from w w w .ja va 2 s . c o 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:Main.java
@Override public void start(Stage stage) { rootNode.setExpanded(true);/*from ww w . j a v a2 s.com*/ 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:musicmetadatak1009705.FolderTreeView.java
public TreeView<File> proxyCreateNode(ArrayList<TreeItem> arrayListTreeItem) { TreeItem<File> proxyItem = new TreeItem<>(); proxyItem.setExpanded(true);//from www . j a va2s . c om for (TreeItem<File> item : arrayListTreeItem) { proxyItem.getChildren().addAll(item); } TreeView<File> tree = new TreeView<>(proxyItem); tree.setShowRoot(false); return tree; }
From source file:com.cdd.bao.editor.EditSchema.java
public EditSchema(Stage stage) { this.stage = stage; if (MainApplication.icon != null) stage.getIcons().add(MainApplication.icon); menuBar = new MenuBar(); menuBar.setUseSystemMenuBar(true);/* ww w . j av a 2s.c om*/ menuBar.getMenus().add(menuFile = new Menu("_File")); menuBar.getMenus().add(menuEdit = new Menu("_Edit")); menuBar.getMenus().add(menuValue = new Menu("_Value")); menuBar.getMenus().add(menuView = new Menu("Vie_w")); createMenuItems(); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true); treeView.setCellFactory(p -> new HierarchyTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> { if (oldVal != null) pullDetail(oldVal); if (newVal != null) pushDetail(newVal); }); treeView.focusedProperty() .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree())); detail = new DetailPane(this); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(detail); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); progBar = new ProgressBar(); progBar.setMaxWidth(Double.MAX_VALUE); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); root.setBottom(progBar); BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2)); Scene scene = new Scene(root, 1000, 800, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template"))); treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays"))); treeTemplate.setExpanded(true); treeAssays.setExpanded(true); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item stage.setOnCloseRequest(event -> { if (!confirmClose()) event.consume(); }); updateTitle(); // loading begins in a background thread, and is updated with a status bar Vocabulary.Listener listener = new Vocabulary.Listener() { public void vocabLoadingProgress(Vocabulary vocab, float progress) { Platform.runLater(() -> { progBar.setProgress(progress); if (vocab.isLoaded()) root.getChildren().remove(progBar); }); } public void vocabLoadingException(Exception ex) { ex.printStackTrace(); } }; Vocabulary.globalInstance(listener); }
From source file:Testing.TestMain.java
public static void treeSample(Stage stage, Collection root) { TreeItem<String> rootItem = new TreeItem<String>("D:\\"); rootItem.setExpanded(true);/*from w w w. ja va 2 s. com*/ for (Iterator it = root.iterator(); it.hasNext();) { Object i = it.next(); TreeItem<String> item = new TreeItem<String>(i.toString()); rootItem.getChildren().add(item); } /* for (int i = 1; i < 6; i++) { TreeItem<String> item = new TreeItem<String>("Message" + i); rootItem.getChildren().add(item); }*/ TreeView<String> tree = new TreeView<String>(rootItem); StackPane rootpane = new StackPane(); rootpane.getChildren().add(tree); stage.setScene(new Scene(rootpane, 300, 250)); stage.show(); }
From source file:be.makercafe.apps.makerbench.Main.java
/** * Creates the viewer control//www . ja va2s . c o m * * @return */ private TreeView<String> createViewer() { TreeView<String> viewer = new TreeView<String>(setRootFolder(new File(this.pathMakerbenchHome))); viewer.setMinWidth(200.0); viewer.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); viewer.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); // System.out.println("Selected Text : " + item.getValue()); createEditor(item.getValue(), item.getPath(), null); } else if (mouseEvent.getButton() == MouseButton.SECONDARY) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); if (item.getPath().toFile().isFile()) { viewer.getContextMenu().getItems().get(0).setDisable(true); viewer.getContextMenu().getItems().get(1).setDisable(true); viewer.getContextMenu().getItems().get(2).setDisable(true); } else { viewer.getContextMenu().getItems().get(0).setDisable(false); viewer.getContextMenu().getItems().get(1).setDisable(false); viewer.getContextMenu().getItems().get(2).setDisable(false); } } } }); viewer.setContextMenu(rootContextMenu); viewer.setEditable(false); viewer.setShowRoot(false); return viewer; }