Java Code Examples for javafx.scene.control.TreeView#setShowRoot()
The following examples show how to use
javafx.scene.control.TreeView#setShowRoot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeViewFactory.java From ariADDna with Apache License 2.0 | 6 votes |
/** * 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 = makeBranch(new SimpleTreeElement("Folder1", 1), root); TreeItem<SimpleTreeElement> outer2 = makeBranch(new SimpleTreeElement("Documents", 2), root); TreeItem<SimpleTreeElement> inner1; TreeItem<SimpleTreeElement> inner2; 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; }
Example 2
Source File: NormalLiveDirs.java From LiveDirsFX with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void start(Stage primaryStage) { TreeView<Path> view = new TreeView<>(); view.setShowRoot(false); try { // create a LiveDirs instance for use on the JavaFX Application Thread LiveDirs<ChangeSource, Path> dirs = LiveDirs.getInstance(ChangeSource.EXTERNAL); // set directory to watch dirs.addTopLevelDirectory(Paths.get(System.getProperty("user.home"), "Documents").toAbsolutePath()); view.setRoot(dirs.model().getRoot()); // stop DirWatcher's thread primaryStage.setOnCloseRequest(val -> dirs.dispose()); } catch (IOException e) { e.printStackTrace(); } primaryStage.setScene(new Scene(view, 500, 500)); primaryStage.show(); }
Example 3
Source File: AnchorFX_CommonStations.java From AnchorFX with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 4
Source File: AnchorFX_settings.java From AnchorFX with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: AnchorFX_test.java From AnchorFX with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 6
Source File: DockFX.java From DockFX with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 7
Source File: TreeViewFactory.java From ariADDna with Apache License 2.0 | 6 votes |
/** * 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 = makeBranch(new SimpleTreeElement("Account", 1), root); TreeItem<SimpleTreeElement> outer2 = makeBranch(new SimpleTreeElement("Clouds", 2), root); TreeItem<SimpleTreeElement> inner1; TreeItem<SimpleTreeElement> inner2; 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; }
Example 8
Source File: TreeViewSample1.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 9
Source File: CheckBoxTreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 10
Source File: ComboBoxTreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 11
Source File: ChoiceBoxTreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 12
Source File: TextFieldTreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 13
Source File: TreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 14
Source File: TreeViewSample.java From marathonv5 with Apache License 2.0 | 6 votes |
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); }
Example 15
Source File: TreeMenu.java From SmartCity-ParkingManagement with Apache License 2.0 | 5 votes |
@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(); }
Example 16
Source File: TreeViewApp.java From oim-fx with MIT License | 4 votes |
public Parent createContent() { 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"))); Button button = new Button(); button.setText("root"); button.setOnMouseEntered(e->{ System.out.println(3333); }); TreeItem<Button> root = new TreeItem<Button>(button); Button nodeButton = new Button(); nodeButton.setText("node"); TreeItem<Button> node = new TreeItem<Button>(nodeButton); root.getChildren().add(node); TreeView<Button> treeView = new TreeView<Button>(); treeView.setShowRoot(true); treeView.setRoot(root); // treeRoot.setExpanded(true); treeView.setOnMouseEntered(e->{ System.out.println(1111); }); return treeView; }
Example 17
Source File: ListKMLContentsSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { try { // create stack pane and application scene StackPane stackPane = new StackPane(); Scene fxScene = new Scene(stackPane); // set title, size, and add scene to stage stage.setTitle("List KML Contents Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(fxScene); stage.show(); // create a map and add it to the map view ArcGISScene scene = new ArcGISScene(Basemap.createImageryWithLabels()); sceneView = new SceneView(); sceneView.setArcGISScene(scene); // load a KML dataset from a local KMZ file and show it as an operational layer File kmzFile = new File(System.getProperty("data.dir"), "./samples-data/kml/esri_test_data.kmz"); KmlDataset kmlDataset = new KmlDataset(kmzFile.getAbsolutePath()); KmlLayer kmlLayer = new KmlLayer(kmlDataset); scene.getOperationalLayers().add(kmlLayer); // create a tree view to list the contents of the KML dataset TreeView<KmlNode> kmlTree = new TreeView<>(); kmlTree.setMaxSize(300, 400); TreeItem<KmlNode> root = new TreeItem<>(null); kmlTree.setRoot(root); kmlTree.setShowRoot(false); // when the dataset is loaded, recursively build the tree view with KML nodes starting with the root node(s) kmlDataset.addDoneLoadingListener(() -> kmlDataset.getRootNodes().forEach(kmlNode -> { TreeItem<KmlNode> kmlNodeTreeItem = buildTree(new TreeItem<>(kmlNode)); root.getChildren().add(kmlNodeTreeItem); })); // show the KML node in the tree view with its name and type kmlTree.setCellFactory(param -> new TextFieldTreeCell<>(new StringConverter<KmlNode>() { @Override public String toString(KmlNode node) { String type = null; if (node instanceof KmlDocument) { type = "KmlDocument"; } else if (node instanceof KmlFolder) { type = "KmlFolder"; } else if (node instanceof KmlGroundOverlay) { type = "KmlGroundOverlay"; } else if (node instanceof KmlScreenOverlay) { type = "KmlScreenOverlay"; } else if (node instanceof KmlPlacemark) { type = "KmlPlacemark"; } return node.getName() + " - " + type; } @Override public KmlNode fromString(String string) { return null; //not needed } })); // when a tree item is selected, zoom to its node's extent (if it has one) kmlTree.getSelectionModel().selectedItemProperty().addListener(o -> { TreeItem<KmlNode> selectedTreeItem = kmlTree.getSelectionModel().getSelectedItem(); KmlNode selectedNode = selectedTreeItem.getValue(); Envelope nodeExtent = selectedNode.getExtent(); if (nodeExtent != null && !nodeExtent.isEmpty()) { sceneView.setViewpointAsync(new Viewpoint(nodeExtent)); } }); // add the map view to stack pane stackPane.getChildren().addAll(sceneView, kmlTree); StackPane.setAlignment(kmlTree, Pos.TOP_LEFT); StackPane.setMargin(kmlTree, new Insets(10)); } catch (Exception e) { // on any error, display the stack trace. e.printStackTrace(); } }
Example 18
Source File: GroupLayersSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 4 votes |
@Override public void start(Stage stage) { try { // set the title and size of the stage and show it StackPane stackPane = new StackPane(); Scene fxScene = new Scene(stackPane); stage.setTitle("Group Layers Sample"); stage.setWidth(800); stage.setHeight(700); // create a JavaFX scene with a stackpane and set it to the stage stage.setScene(fxScene); stage.show(); // create a scene view and add it to the stack pane sceneView = new SceneView(); stackPane.getChildren().add(sceneView); // create a scene with a basemap and add it to the scene view scene = new ArcGISScene(); scene.setBasemap(Basemap.createImagery()); sceneView.setArcGISScene(scene); // set the base surface with world elevation Surface surface = new Surface(); surface.getElevationSources().add(new ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); scene.setBaseSurface(surface); // create different types of layers ArcGISSceneLayer devABuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_BuildingShells/SceneServer"); ArcGISSceneLayer devBBuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevB_BuildingShells/SceneServer"); ArcGISSceneLayer devATrees = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Trees/SceneServer"); FeatureLayer devAPathways = new FeatureLayer(new ServiceFeatureTable(" https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Pathways/FeatureServer/1")); FeatureLayer devProjectArea = new FeatureLayer(new ServiceFeatureTable("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevelopmentProjectArea/FeatureServer/0")); // create a group layer from scratch by adding the layers as children groupLayer = new GroupLayer(); groupLayer.setName("Group: Dev A"); groupLayer.getLayers().addAll(Arrays.asList(devATrees, devAPathways, devABuildings)); // add the group layer and other layers to the scene as operational layers scene.getOperationalLayers().addAll(Arrays.asList(groupLayer, devBBuildings, devProjectArea)); // zoom to the extent of the group layer when the child layers are loaded groupLayer.getLayers().forEach(childLayer -> childLayer.addDoneLoadingListener(() -> { if (childLayer.getLoadStatus() == LoadStatus.LOADED) { sceneView.setViewpointCamera(new Camera(groupLayer.getFullExtent().getCenter(), 700, 0, 60, 0)); } }) ); // create a JavaFX tree view to show the layers in the scene TreeView<Layer> layerTreeView = new TreeView<>(); layerTreeView.setMaxSize(250, 200); TreeItem<Layer> rootTreeItem = new TreeItem<>(); layerTreeView.setRoot(rootTreeItem); layerTreeView.setShowRoot(false); StackPane.setAlignment(layerTreeView, Pos.TOP_RIGHT); StackPane.setMargin(layerTreeView, new Insets(10)); stackPane.getChildren().add(layerTreeView); // display each layer with a custom tree cell layerTreeView.setCellFactory(p -> new LayerTreeCell()); // recursively build the table of contents from the scene's operational layers buildLayersView(rootTreeItem, scene.getOperationalLayers()); } catch (Exception e) { // on any error, display the stack trace. e.printStackTrace(); } }
Example 19
Source File: ResourceView.java From sis with Apache License 2.0 | 4 votes |
public ResourceView() { pane.setStyle("-fx-background-color: linear-gradient(to bottom right, #aeb7c4, #fafafa);"); final VBox dragTarget = new VBox(); root.setExpanded(true); final TreeView<Label> resources = new TreeView<>(root); resources.setStyle("-fx-background-color: rgba(77, 201, 68, 0.4);"); resources.setShowRoot(false); resources.setOnDragOver(event -> { if (event.getGestureSource() != dragTarget && event.getDragboard().hasFiles()) { event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } event.consume(); }); resources.setOnDragDropped(event -> { Dragboard db = event.getDragboard(); boolean success = false; File firstFile = db.getFiles().get(0); if (firstFile.isDirectory()) { openDirectory(firstFile); success = true; } else { if (db.hasFiles()) { success = true; } List<?> fileList = (List<?>) db.getContent(DataFormat.FILES); // To open multiple files in one drop. for (Object item : fileList) { File f = (File) item; openFile(f); } } event.setDropCompleted(success); event.consume(); }); // Link to the temporary varaible see above. This is a temporary part. temporarySauv = root.getChildren(); temporarySauv.addListener((ListChangeListener.Change<? extends TreeItem<Label>> c) -> { c.next(); if (c.wasRemoved()) { temp.addAll(c.getRemoved()); } }); pane.getItems().add(resources); }
Example 20
Source File: MainView.java From Notebook with Apache License 2.0 | 4 votes |
@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>("�ʼ�������",emailIcon); TreeItem<String> item_5 = new TreeItem<String>("ϵͳ����",threeIcon); treeItemRoot.getChildren().addAll(Arrays.asList(item_1, item_2, item_3, item_4, item_5)); 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(4).getChildren().addAll(Arrays.asList(item_4_1, item_4_2, item_4_3, item_4_4)); treeItemRoot.setExpanded(true); item_5.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 "�ʼ�������": setSelection(main_center, FRAGMENT_EMAIL); break; case "�˳�": Platform.exit(); break; default: break; } } }); main_left.getChildren().add(treeView); intSelection(main_center); return parent; }