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


Java TreeView.setShowRoot方法代码示例

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


在下文中一共展示了TreeView.setShowRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createFilteredTree

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
private Node createFilteredTree() {
    FilterableTreeItem<Actor> root = getTreeModel();
    root.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        if (filterField.getText() == null || filterField.getText().isEmpty())
            return null;
        return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText()));
    }, filterField.textProperty()));

    TreeView<Actor> treeView = new TreeView<>(root);
    treeView.setShowRoot(false);

    TitledPane pane = new TitledPane("Filtered TreeView", treeView);
    pane.setCollapsible(false);
    pane.setMaxHeight(Double.MAX_VALUE);
    return pane;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:17,代码来源:FilterableTreeItemDemo.java

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

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

示例10: generateRandomTree

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
private TreeView<String> generateRandomTree() {
    // create a demonstration tree view to use as the contents for a dock node
    TreeItem<String> root = new TreeItem<String>("Root");
    TreeView<String> treeView = new TreeView<String>(root);
    treeView.setShowRoot(false);

    // populate the prototype tree with some random nodes
    Random rand = new Random();
    for (int i = 4 + rand.nextInt(8); i > 0; i--) {
        TreeItem<String> treeItem = new TreeItem<String>("Item " + i);
        root.getChildren().add(treeItem);
        for (int j = 2 + rand.nextInt(4); j > 0; j--) {
            TreeItem<String> childItem = new TreeItem<String>("Child " + j);
            treeItem.getChildren().add(childItem);
        }
    }

    return treeView;
}
 
开发者ID:alexbodogit,项目名称:AnchorFX,代码行数:20,代码来源:AnchorFX_test.java

示例11: start

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
@Override
public void start(final Stage primaryStage) {
	window = primaryStage;
	window.setTitle("Tree Menu");

	// Tree
	final TreeItem<String> root = new TreeItem<>();
	root.setExpanded(true);

	// Parking colors
	final TreeItem<String> colors = makeBranch("Colors", root);
	makeBranch("Blue", colors);
	makeBranch("Red", colors);
	makeBranch("Green", colors);

	// Parking areas
	final TreeItem<String> areas = makeBranch("Areas", root);
	makeBranch("Dorms", areas);
	makeBranch("All around", areas);
	makeBranch("Taub", areas);
	areas.setExpanded(false);

	// Set Tree
	final TreeView<String> tree = new TreeView<>(root);
	tree.setShowRoot(false);
	tree.getSelectionModel().selectedItemProperty().addListener((v, oldValue, newValue) -> {
		if (newValue != null)
			System.out.println(newValue);
	});

	// Layout
	final StackPane layout = new StackPane();
	layout.getChildren().add(tree);
	window.setScene(new Scene(layout, 300, 300));
	window.show();
}
 
开发者ID:TechnionYP5777,项目名称:SmartCity-ParkingManagement,代码行数:37,代码来源:TreeMenu.java

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

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

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

示例15: initAccountsTreeView

import javafx.scene.control.TreeView; //导入方法依赖的package包/类
private void initAccountsTreeView(){

        TreeItem<CloudSettings> root = new TreeItem<>(new CloudSettings());
        for (CloudSettings setting:settingsMananger.getCloudAccounts()) {
            TreeItem<CloudSettings> item = new TreeItem<>(setting, new ImageView(setting.getImage()));
            root.getChildren().add(item);
        }
        TreeView<CloudSettings> accountsTree = new TreeView<>(root);
        accountsTree.setShowRoot(false);
        accountsTreePane.getChildren().add(accountsTree);

        accountsTree.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
            CloudSettings set = newValue.getValue();

            updateChart(set);
            cloudNameLable.setGraphic(new ImageView(set.getBigImage()));
            cloudNameLable.setText(set.getName());


            totalSpaceLable.setText(String.valueOf(set.getTotalSpace()));
            availableSpaceLable.setText(String.valueOf(set.getAvailableSpace()));
            cloudRaidSpaceLable.setText(String.valueOf(set.getCloudRaidSpace()));
            cloudRaidSpaceSlider.setMax(set.getTotalSpace());
            cloudRaidSpaceSlider.setMin(0);
            cloudRaidSpaceSlider.adjustValue(set.getCloudRaidSpace());
            cloudRaidSpaceSlider.valueProperty().addListener((observable1, oldValue1, newValue1) -> {
                cloudRaidSpaceLable.setText(String.valueOf(newValue1.longValue()));
            });
            cloudRaidSpaceSlider.setOnMouseReleased(event -> {
                set.setCloudRaidSpace((long) cloudRaidSpaceSlider.getValue());
                availableSpaceLable.setText(String.valueOf(set.getAvailableSpace()));
                updateChart(set);
            });





        });


    }
 
开发者ID:StnetixDevTeam,项目名称:CloudRaid-DesktopApp,代码行数:43,代码来源:SettingsController.java


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