当前位置: 首页>>代码示例>>Java>>正文


Java TreeView.setRoot方法代码示例

本文整理汇总了Java中javafx.scene.control.TreeView.setRoot方法的典型用法代码示例。如果您正苦于以下问题:Java TreeView.setRoot方法的具体用法?Java TreeView.setRoot怎么用?Java TreeView.setRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.TreeView的用法示例。


在下文中一共展示了TreeView.setRoot方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: CheckBoxTreeViewSample

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
public CheckBoxTreeViewSample() {
    final CheckBoxTreeItem<String> treeRoot = new CheckBoxTreeItem<String>("Root node");
    treeRoot.getChildren().addAll(Arrays.asList(new CheckBoxTreeItem<String>("Child Node 1"),
            new CheckBoxTreeItem<String>("Child Node 2"), new CheckBoxTreeItem<String>("Child Node 3")));

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

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

    getChildren().add(treeView);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:CheckBoxTreeViewSample.java

示例6: TreeViewSample1

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
public TreeViewSample1() {
    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"),
                    new TreeItem<String>("Child Node 13"), new TreeItem<String>("Child Node 14"),
                    new TreeItem<String>("Child Node 15"), new TreeItem<String>("Child Node 16"),
                    new TreeItem<String>("Child Node 17"), new TreeItem<String>("Child Node 18"),
                    new TreeItem<String>("Child Node 19"), new TreeItem<String>("Child Node 20"),
                    new TreeItem<String>("Child Node 21"), new TreeItem<String>("Child Node 22"),
                    new TreeItem<String>("Child Node 23"), new TreeItem<String>("Child Node 24")));

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

    getChildren().add(treeView);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:TreeViewSample1.java

示例7: CreateTreeView

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
public void CreateTreeView(TreeView<String> treeview){
    File[] sysroots = File.listRoots();
    TreeItem<String> ThisPc = new TreeItem<>("This PC", new ImageView(new Image(ClassLoader.getSystemResourceAsStream("img/pc.png"))));
    TreeItem<String>[] drives = new TreeItem[sysroots.length];
    for(int i=0; i<sysroots.length;i++){
        drives[i] = new TreeItem<>(sysroots[i].getAbsolutePath(), new ImageView(new Image(ClassLoader.getSystemResourceAsStream("img/thumb_Hard_Drive.png"))));
        try{
            drives[i].getChildren().addAll(TreeCreate(sysroots[i]));
        }catch(NullPointerException x){System.out.println("Exeption x detected: "+x.fillInStackTrace()+drives[i].toString());}
        finally {
            ThisPc.getChildren().add(drives[i]);
        }
    }
    treeview.setRoot(ThisPc);
}
 
开发者ID:maximstewart,项目名称:UDE,代码行数:17,代码来源:ClassTreeView.java

示例8: start

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);

    final TreeView<Data> treeView = new TreeView<>();
    treeView.setEditable(true);
    treeView.setId(TREE_VIEW_ID);
    treeView.setRoot(new TreeItem(new Data("0")));
    addContent(treeView.getRoot(), 2, 4, "0");
    treeView.setCellFactory(p -> new TextFieldTreeCell());
    VBox vBox = new VBox();
    vBox.getChildren().setAll(treeView);

    Scene scene = new Scene(vBox, 800, 500);

    stage.setScene(scene);
    stage.show();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:19,代码来源:TreeViewApp.java

示例9: getSimple

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
/**
 * Generate treeView of file items
 * TODO: work with VUFS items
 *
 * @return tree view
 */
public TreeView<SimpleTreeElement> getSimple() {
    TreeView<SimpleTreeElement> tree = new TreeView<>();
    TreeItem<SimpleTreeElement> root = new TreeItem<>(new SimpleTreeElement("root", 0));

    TreeItem<SimpleTreeElement> outer1, outer2, inner1, inner2;
    outer1 = makeBranch(new SimpleTreeElement("Folder1", 1), root);
    outer2 = makeBranch(new SimpleTreeElement("Documents", 2), root);
    makeBranch(new SimpleTreeElement("MyFotos", 3), outer1);
    makeBranch(new SimpleTreeElement("OtherFiles", 4), outer1);
    makeBranch(new SimpleTreeElement("WorkFiles", 5), root);
    makeBranch(new SimpleTreeElement("Projects", 6), root);

    tree.setRoot(root);
    tree.setPrefWidth(200);

    setTreeCellFactory(tree);


    tree.setShowRoot(false);
    return tree;

}
 
开发者ID:StnetixDevTeam,项目名称:ariADDna,代码行数:29,代码来源:TreeViewFactory.java

示例10: getSettingsTree

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
/**
 * Generate treeView of settings items
 * TODO: work with Repository
 *
 * @return tree view
 */
public TreeView<SimpleTreeElement> getSettingsTree() {
    TreeView<SimpleTreeElement> tree = new TreeView<>();
    TreeItem<SimpleTreeElement> root = new TreeItem<>(new SimpleTreeElement("root", 0));

    TreeItem<SimpleTreeElement> outer1, outer2, inner1, inner2;
    outer1 = makeBranch(new SimpleTreeElement("Account", 1), root);
    outer2 = makeBranch(new SimpleTreeElement("Clouds", 2), root);
    makeBranch(new SimpleTreeElement("Dropbox", 3), outer2);
    makeBranch(new SimpleTreeElement("Google Drive", 4), outer2);
    makeBranch(new SimpleTreeElement("Sync", 5), root);
    makeBranch(new SimpleTreeElement("Encription", 6), root);

    tree.setRoot(root);
    tree.setPrefWidth(200);

    setTreeCellFactory(tree);


    tree.setShowRoot(false);

    return tree;
}
 
开发者ID:StnetixDevTeam,项目名称:ariADDna,代码行数:29,代码来源:TreeViewFactory.java

示例11: createLicenseTreePane

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
/**
 * Create a pane for displaying license information in a readable form.
 * 
 * @param dirBase
 * @return
 */
private Pane createLicenseTreePane(final File dirBase) {
	TreeView<File> tree = new TreeView<>();
	tree.setRoot(new LicenseFileTreeItem(dirBase));
	tree.setShowRoot(false);
	
	TextArea textArea = new TextArea();
	textArea.setStyle("-fx-font-family: monospace");
	textArea.setWrapText(true);
	
	// Show content for selected node
	tree.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
		if (n instanceof LicenseFileTreeItem)
			textArea.setText(((LicenseFileTreeItem)n).getContents());
	});
	
	tree.setCellFactory(n -> new FileTreeCell());
	
	Button btnThirdParty = new Button("Open licenses directory");
	File dirLicenses = dirBase;
	btnThirdParty.setOnAction(e -> {
		DisplayHelpers.openFile(dirLicenses);
	});
	btnThirdParty.setMaxWidth(Double.MAX_VALUE);
	

	BorderPane pane = new BorderPane();
	pane.setLeft(tree);
	pane.setCenter(textArea);
	pane.setBottom(btnThirdParty);
	
	return pane;
}
 
开发者ID:qupath,项目名称:qupath,代码行数:39,代码来源:ShowLicensesCommand.java

示例12: getView

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
public Parent getView() {
		Parent parent = LayoutInflater.inflate("activity_main", Parent.class);
		parent.getStylesheets().add("css/main.css");

		AnchorPane main_left = (AnchorPane) parent.lookup("#main_left");
		StackPane main_center = (StackPane) parent.lookup("#main_center");

		// left
		TreeView treeView = new TreeView();
		// TreeView������Ҳ�Ƿ�Node���ͣ����Բ�����SceneBuilder��ͼ��
	    TreeItem<String> treeItemRoot = new TreeItem<String>("�����˵�",rootIcon);

		TreeItem<String> item_1 = new TreeItem<String>("���¹���",oneIcon);
		TreeItem<String> item_2 = new TreeItem<String>("������",twoIcon);
		TreeItem<String> item_3 = new TreeItem<String>("���ù���",eightIcon);
		TreeItem<String> item_4 = new TreeItem<String>("ϵͳ����",threeIcon);
	    treeItemRoot.getChildren().addAll(Arrays.asList(item_1,item_2,item_3,item_4));

	    TreeItem<String> item_4_1 = new TreeItem<String>("����",fourIcon);
	    TreeItem<String> item_4_2 = new TreeItem<String>("����",fiveIcon);
	    TreeItem<String> item_4_3 = new TreeItem<String>("ͬ��",sixIcon);
	    TreeItem<String> item_4_4 = new TreeItem<String>("�˳�",sevenIcon);
	    treeItemRoot.getChildren().get(3).getChildren().addAll(Arrays.asList(item_4_1,item_4_2,item_4_3,item_4_4));

	    treeItemRoot.setExpanded(true);
	    item_4.setExpanded(true);

        treeView.setShowRoot(true);
        treeView.setRoot(treeItemRoot);
        treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {

			@Override
			public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue,
					TreeItem<String> newValue) {
				Parent container = null;
				switch (newValue.getValue()) {
				case "���¹���":
					setSelection(main_center,FRAGMENT_ARTICLE);
					break;
				case "������":
					setSelection(main_center, FRAGMENT_CATEGORY);
					break;
				case "����":
					setSelection(main_center, FRAGMENT_SETTING);
					break;
				case "����":
					setSelection(main_center, FRAGMENT_DEPLOY);
					break;
				case "ͬ��":
					setSelection(main_center, FRAGMENT_SYNC);
					break;
				case "���ù���":
					setSelection(main_center, FRAGMENT_TOOL);
					break;
				case "�˳�":
					Platform.exit();
					break;
				default:
					break;
				}
			}

		});

        main_left.getChildren().add(treeView);
        intSelection(main_center);
        return parent;
}
 
开发者ID:coding-dream,项目名称:Notebook,代码行数:70,代码来源:MainView.java

示例13: start

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
	public void start(Stage primaryStage) throws Exception {

		FilterableTreeItem<String> filterableTreeItem = new FilterableTreeItem<>("");
		filterableTreeItem.setExpanded(true);
		TreeView<String> treeView = new TreeView<>(filterableTreeItem);
		treeView.setShowRoot(false);
		treeView.setRoot(filterableTreeItem);

		BorderPane borderPane = new BorderPane(treeView);
		TextField value = new TextField();
		value.textProperty().addListener((oba, oldval, newval) -> {
			Callable<TreeItemPredicate<String>> func = () -> {
				Predicate<String> predicate = str -> str.indexOf(newval) >= 0;
				return TreeItemPredicate.<String> create(predicate);
			};
			ObjectBinding<TreeItemPredicate<String>> createObjectBinding = Bindings.createObjectBinding(func, hide);
			filterableTreeItem.predicateProperty().bind(createObjectBinding);
		});

		borderPane.setTop(value);
		Scene scene = new Scene(borderPane);

		primaryStage.setScene(scene);

		primaryStage.show();

		FilterableTreeItem<String> e = new FilterableTreeItem<>("ABC");
//		e.getChildren().add(new FilterableTreeItem<>("DEF"));
//		e.getChildren().add(new FilterableTreeItem<>("김aa"));
//		e.getChildren().add(new FilterableTreeItem<>("김bb"));
//		e.getChildren().add(new FilterableTreeItem<>("김cc"));
//		filterableTreeItem.getChildren().add(e);
//		filterableTreeItem.getChildren().add(new FilterableTreeItem<>("DEF"));
//		filterableTreeItem.getChildren().add(new FilterableTreeItem<>("김DD"));
//
		e.getSourceChildren().add(new FilterableTreeItem<>("DEF"));
		e.getSourceChildren().add(new FilterableTreeItem<>("김aa"));
		e.getSourceChildren().add(new FilterableTreeItem<>("김bb"));
		e.getSourceChildren().add(new FilterableTreeItem<>("김cc"));
		filterableTreeItem.getSourceChildren().add(e);
		filterableTreeItem.getSourceChildren().add(new FilterableTreeItem<>("DEF"));
		filterableTreeItem.getSourceChildren().add(new FilterableTreeItem<>("김DD"));

		// filterableTreeItem.predicateProperty()
		// .bind(Bindings.createObjectBinding(() ->
		// TreeItemPredicate<String>.create(str -> str.indexOf("김") >= 0),
		// hide));

	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:51,代码来源:FilteredTreeItemExam.java

示例14: createContent

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
public Node createContent() {
    final BorderPane borderPane = new BorderPane();
    factoryLogRootUpdater= root -> {
        TreeView<FactoryLogWidgetTreeData> treeView = new TreeView<>();
        if (factoryLog.root!=null){
            treeView.setRoot(createLogTree(factoryLog.root, System.currentTimeMillis()+5000,new HashMap<>()));
        }
        treeView.setCellFactory(param-> new TextFieldTreeCell<FactoryLogWidgetTreeData>(){
            @Override
            public void updateItem(FactoryLogWidgetTreeData item, boolean empty) {
                super.updateItem(item, empty);
                if (!empty) {
                    setText(item.getText());
                    setGraphic(uniformDesign.createIcon(item.getIcon()));
                }
            }
        });
        final TabPane tabPane = new TabPane();
        tabPane.getStyleClass().add("floating");

        final Tab treeTab = new Tab("Updated Tree");
        treeTab.setContent(treeView);
        tabPane.getTabs().add(treeTab);

        final Tab tableTab = new Tab("Updated Table");
        tableTab.setContent(treeView);
        if (factoryLog.root!=null){
            tableTab.setContent(createTable(factoryLog.root.getListDeep()));
        }
        tabPane.getTabs().add(tableTab);

        final Tab removedTab = new Tab("Removed");
        removedTab.setContent(treeView);
        removedTab.setContent(createTable(factoryLog.removedFactoryLogs));
        tabPane.getTabs().add(removedTab);

        borderPane.setCenter(tabPane);
        final Label totalDuarion = new Label("total update duration: " + (factoryLog.totalDurationNs / 1000000.0) + "ms");
        BorderPane.setMargin(totalDuarion,new Insets(3));
        borderPane.setTop(totalDuarion);
    };
    if (factoryLog!=null) {
        factoryLogRootUpdater.accept(factoryLog);
    }
    return borderPane;
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:48,代码来源:FactoryUpdateLogWidget.java


注:本文中的javafx.scene.control.TreeView.setRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。