当前位置: 首页>>代码示例>>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;未经允许,请勿转载。