當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeView類代碼示例

本文整理匯總了Java中javafx.scene.control.TreeView的典型用法代碼示例。如果您正苦於以下問題:Java TreeView類的具體用法?Java TreeView怎麽用?Java TreeView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TreeView類屬於javafx.scene.control包,在下文中一共展示了TreeView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTreeView

import javafx.scene.control.TreeView; //導入依賴的package包/類
public TreeView<Concept> getTreeView() {
    if (treeView == null) {
        TreeCellFactory cellFactory = new TreeCellFactory(conceptService);
        treeView = new TreeView<>();
        treeView.getStyleClass().add("concepttree-treeview");
        treeView.setEditable(false);
        treeView.setCellFactory(tv -> cellFactory.build());
        treeView.setContextMenu(getContextMenu());
        conceptService.findRoot()
                .thenApply(root -> {
                    Platform.runLater(() -> {
                        TreeItem<Concept> rootItem = buildTreeItem(root, null);
                        treeView.setRoot(rootItem);
                    });
                    return null;
                });
    }
    return treeView;
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:20,代碼來源:TreeViewController.java

示例2: setNowObject

import javafx.scene.control.TreeView; //導入依賴的package包/類
public static synchronized void setNowObject(Object obj, Field f){
	if (!start)
		start();
	while (!start)
		Animation.sleepSeconds(1);
	PlatformImpl.startup(() -> {});
	Platform.runLater(() -> {
		TreeItem<String> rootItem = new TreeItem<String>((f == null ? "" : f.getName()) + obj.getClass().getName() + " : " + obj);
		TreeView<String> tree = new TreeView<String> (rootItem);
		rootItem.setExpanded(true);
		try {
			addChildren(obj, obj, f, null, rootItem);
		} catch(Exception e){e.printStackTrace();}
		StackPane root = new StackPane();
		root.getChildren().add(tree);
		stage.setScene(new Scene(root));
	});
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:19,代碼來源:ActivityTreeViewSample.java

示例3: setTreeCellFactory

import javafx.scene.control.TreeView; //導入依賴的package包/類
/**
 * Customizing treeView
 *
 * @param tree treeView
 */
private void setTreeCellFactory(TreeView<SimpleTreeElement> tree) {
    tree.setCellFactory(param -> new TreeCell<SimpleTreeElement>() {
        @Override
        public void updateItem(SimpleTreeElement item, boolean empty) {
            super.updateItem(item, empty);
            //setDisclosureNode(null);

            if (empty) {
                setText("");
                setGraphic(null);
            } else {
                setText(item.getName());
            }
        }

    });

    tree.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            System.out.println(newValue.getValue());
        }
    });
}
 
開發者ID:StnetixDevTeam,項目名稱:ariADDna,代碼行數:29,代碼來源:TreeViewFactory.java

示例4: setAction

import javafx.scene.control.TreeView; //導入依賴的package包/類
/**
 * 點擊處理方法.
 *
 * @param treeView treeView
 */
@Override
protected void setAction(TreeView treeView) {
    super.setOnAction(
        (event) -> {
            TreeItem<Label> item = (TreeItem) treeView.getSelectionModel().getSelectedItem();
            String flag = item.getValue().getAccessibleHelp();
            if ("link".equals(flag)) {
                String poolId = item.getValue().getAccessibleText();
                ConnectPanel connectPanel = new ConnectPanel();
                connectPanel.isNewLink(false);
                connectPanel.showConnectPanel(poolId);
            }
        }
    );
}
 
開發者ID:Kuangcp,項目名稱:MythRedisClient,代碼行數:21,代碼來源:AttributeSetMenu.java

示例5: TreeViewSample

import javafx.scene.control.TreeView; //導入依賴的package包/類
public TreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 1"),
            new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(
            new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"),
            new TreeItem<String>("Child Node 6"),
            new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"),
            new TreeItem<String>("Child Node 9"),
            new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"),
            new TreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);

    getChildren().add(treeView);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:26,代碼來源:TreeViewSample.java

示例6: initTreeView

import javafx.scene.control.TreeView; //導入依賴的package包/類
private void initTreeView() {
    parentTreeView.setCellFactory(new Callback<TreeView<File>, TreeCell<File>>() {
        @Override public TreeCell<File> call(TreeView<File> param) {
            return new ParentFileCell();
        }
    });
    parentTreeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newVlaue) -> {
        TreeItem<File> selectedItem = parentTreeView.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            newFolderButton.setDisable(false);
            fileNameBox.setEditable(true);
            File selectedFile = selectedItem.getValue();
            fillUpChildren(selectedFile);
        } else {
            fileNameBox.setEditable(false);
            newFolderButton.setDisable(true);
            childrenListView.getItems().clear();
        }
    });
    File root = fileChooserInfo.getRoot();
    TreeItem<File> rootItem = new TreeItem<>(root);
    parentTreeView.setRoot(rootItem);
    rootItem.setExpanded(true);
    parentTreeView.getSelectionModel().select(0);
    populateChildren(root, rootItem);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:27,代碼來源:MarathonFileChooser.java

示例7: createTree

import javafx.scene.control.TreeView; //導入依賴的package包/類
private Node createTree() {
    VBox treeContentBox = new VBox();
    tree.setRoot(functionInfo.getRoot(true));
    tree.setShowRoot(false);
    tree.getSelectionModel().selectedItemProperty().addListener(new TreeViewSelectionChangeListener());
    tree.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
        @Override public TreeCell<Object> call(TreeView<Object> param) {
            return new FunctionTreeCell();
        }
    });
    filterByName.setOnAction((e) -> {
        tree.setRoot(functionInfo.refreshNode(filterByName.isSelected()));
        expandAll();
    });
    filterByName.setSelected(true);
    expandAll();
    treeContentBox.getChildren().addAll(topButtonBar, tree, filterByName);
    VBox.setVgrow(tree, Priority.ALWAYS);
    return treeContentBox;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:FunctionStage.java

示例8: getRowAt

import javafx.scene.control.TreeView; //導入依賴的package包/類
public int getRowAt(TreeView<?> treeView, Point2D point) {
    if (point == null) {
        return treeView.getSelectionModel().getSelectedIndex();
    }
    point = treeView.localToScene(point);
    int itemCount = treeView.getExpandedItemCount();
    @SuppressWarnings("rawtypes")
    List<TreeCell> cells = new ArrayList<>();
    for (int i = 0; i < itemCount; i++) {
        cells.add(getCellAt(treeView, i));
    }
    TreeCell<?> selected = null;
    for (Node cellNode : cells) {
        Bounds boundsInScene = cellNode.localToScene(cellNode.getBoundsInLocal(), true);
        if (boundsInScene.contains(point)) {
            selected = (TreeCell<?>) cellNode;
            break;
        }
    }
    if (selected == null) {
        return -1;
    }
    return selected.getIndex();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:25,代碼來源:JavaFXElementPropertyAccessor.java

示例9: getByPseudoElement

import javafx.scene.control.TreeView; //導入依賴的package包/類
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
    if (selector.equals("select-by-properties")) {
        return findNodeByProperties(new JSONObject((String) params[0]));
    } else if (selector.equals("root")) {
        return Arrays.asList(new JavaFXTreeViewNodeElement(this, 0));
    } else if (selector.equals("nth-node")) {
        return Arrays.asList(new JavaFXTreeViewNodeElement(this, ((Integer) params[0]).intValue() - 1));
    } else if (selector.equals("all-nodes")) {
        TreeView<?> treeView = (TreeView<?>) getComponent();
        ArrayList<IJavaFXElement> r = new ArrayList<>();
        int nrows = treeView.getExpandedItemCount();
        for (int i = 0; i < nrows; i++) {
            r.add(new JavaFXTreeViewNodeElement(this, i));
        }
        return r;
    }
    return super.getByPseudoElement(selector, params);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:JavaFXTreeViewElement.java

示例10: setSelectionPath

import javafx.scene.control.TreeView; //導入依賴的package包/類
@SuppressWarnings("unchecked") private boolean setSelectionPath(String value) {
    TreeView<?> treeView = (TreeView<?>) getComponent();
    JSONArray pathElements = new JSONArray(value);
    List<TreeItem<?>> paths = new ArrayList<>();
    for (int i = 0; i < pathElements.length(); i++) {
        paths.add(getPath(treeView, pathElements.getString(i)));
    }
    treeView.getSelectionModel().clearSelection();
    for (@SuppressWarnings("rawtypes")
    TreeItem treeItem : paths) {
        if (getVisibleCellAt(treeView, treeItem) == null) {
            treeView.scrollTo(treeView.getRow(treeItem));
        }
        treeView.getSelectionModel().select(treeItem);
    }
    return true;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:JavaFXTreeViewElement.java

示例11: selectTreeItemCheckBoxSelectedSelected

import javafx.scene.control.TreeView; //導入依賴的package包/類
@Test public void selectTreeItemCheckBoxSelectedSelected() {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
    treeItem.setSelected(true);
    JSONObject o = new JSONObject();
    o.put("select", "/Root node/Child Node 2");
    IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
    IJavaFXElement cb = item.findElementByCssSelector(".::editor");
    cb.marathon_select("Child Node 2:checked");
    new Wait("Wait for tree item check box to be selected") {
        @Override public boolean until() {
            String selected = cb.getAttribute("selected");
            return selected.equals("true");
        }
    };
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:17,代碼來源:JavaFXTreeViewCheckBoxTreeCellElementTest.java

示例12: selectTreeItemCheckBoxSelectedNotSelected

import javafx.scene.control.TreeView; //導入依賴的package包/類
@Test public void selectTreeItemCheckBoxSelectedNotSelected() {
    TreeView<?> treeViewNode = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view");
    CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeViewNode.getTreeItem(2);
    treeItem.setSelected(true);
    JSONObject o = new JSONObject();
    o.put("select", "/Root node/Child Node 2");
    IJavaFXElement item = treeView.findElementByCssSelector(".::select-by-properties('" + o.toString() + "')");
    IJavaFXElement cb = item.findElementByCssSelector(".::editor");
    cb.marathon_select("Child Node 2:unchecked");
    new Wait("Wait for tree item check box to be deselected") {
        @Override public boolean until() {
            String selected = cb.getAttribute("selected");
            return selected.equals("false");
        }
    };
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:17,代碼來源:JavaFXTreeViewCheckBoxTreeCellElementTest.java

示例13: TextFieldTreeViewSample

import javafx.scene.control.TreeView; //導入依賴的package包/類
public TextFieldTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 1"), new TreeItem<String>("Child Node 2"),
            new TreeItem<String>("Child Node 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Child Node 4"),
            new TreeItem<String>("Child Node 5"), new TreeItem<String>("Child Node 6"), new TreeItem<String>("Child Node 7"),
            new TreeItem<String>("Child Node 8"), new TreeItem<String>("Child Node 9"), new TreeItem<String>("Child Node 10"),
            new TreeItem<String>("Child Node 11"), new TreeItem<String>("Child Node 12")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(TextFieldTreeCell.forTreeView());

    getChildren().add(treeView);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:20,代碼來源:TextFieldTreeViewSample.java

示例14: ChoiceBoxTreeViewSample

import javafx.scene.control.TreeView; //導入依賴的package包/類
public ChoiceBoxTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"),
            new TreeItem<String>("Option 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"),
            new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(ChoiceBoxTreeCell.forTreeView(items));

    getChildren().add(treeView);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:ChoiceBoxTreeViewSample.java

示例15: ComboBoxTreeViewSample

import javafx.scene.control.TreeView; //導入依賴的package包/類
public ComboBoxTreeViewSample() {
    final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 1"), new TreeItem<String>("Option 2"),
            new TreeItem<String>("Option 3")));

    treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(new TreeItem<String>("Option 4"),
            new TreeItem<String>("Option 5"), new TreeItem<String>("Option 6")));

    final TreeView treeView = new TreeView();
    treeView.setShowRoot(true);
    treeView.setRoot(treeRoot);
    treeRoot.setExpanded(true);
    treeView.setEditable(true);
    treeView.setCellFactory(ComboBoxTreeCell.forTreeView(items));

    getChildren().add(treeView);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:ComboBoxTreeViewSample.java


注:本文中的javafx.scene.control.TreeView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。