use of javafx.scene.control.TreeView in project Gargoyle by callakrsos.
the class FilteredTreeItemExam method start.
@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));
}
use of javafx.scene.control.TreeView in project Challenger4SysAdmins by fvarrui.
the class TreeEditorController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
treeView.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
public TreeCell<Object> call(TreeView<Object> param) {
return new CustomTreeCell();
}
});
challenge.addListener((o, ov, nv) -> {
if (nv != null)
treeView.setRoot(new ChallengeTreeItem(nv));
else
treeView.setRoot(null);
});
selectedItem.addListener((o, ov, nv) -> {
if (nv != null) {
seleccionado.set(nv.getValue());
} else {
seleccionado.set(null);
}
});
selectedItem.bind(treeView.getSelectionModel().selectedItemProperty());
addButton.disableProperty().bind(seleccionado.isNull());
deleteButton.disableProperty().bind(seleccionado.isNull());
}
use of javafx.scene.control.TreeView in project blue by kunstmusik.
the class BlueJFXControlsApplication method setTreeViewTest.
private void setTreeViewTest(TabPane root) {
TreeView<String> tv = new TreeView<>();
tv.setRoot(new TreeItem<>("TEST"));
root.getTabs().add(new Tab("TreeView", tv));
}
use of javafx.scene.control.TreeView in project MiscellaneousStudy by mikoto2000.
the class EditableTreeViewController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
// ルートの子要素を作成
TreeItem<String> item1 = new TreeItem<String>("Item 1");
TreeItem<String> item2 = new TreeItem<String>("Item 2");
TreeItem<String> item3 = new TreeItem<String>("Item 3");
TreeItem<String> item4 = new TreeItem<String>("Item 4");
// item4 の子要素
TreeItem<String> item41 = new TreeItem<String>("Item 4-1");
TreeItem<String> item42 = new TreeItem<String>("Item 4-2");
TreeItem<String> item43 = new TreeItem<String>("Item 4-3");
// item4 に子要素を追加する
ObservableList<TreeItem<String>> image4tChildren = item4.getChildren();
image4tChildren.add(item41);
image4tChildren.add(item42);
image4tChildren.add(item43);
TreeItem<String> root = new TreeItem<String>("root");
treeView.setRoot(root);
// ルート要素に子要素を追加する
ObservableList<TreeItem<String>> rootChildren = root.getChildren();
rootChildren.add(item1);
rootChildren.add(item2);
rootChildren.add(item3);
rootChildren.add(item4);
// 子を持つノードを開く
root.setExpanded(true);
item4.setExpanded(true);
// 編集可能にする
treeView.setEditable(true);
treeView.setCellFactory((TreeView<String> p) -> {
TextFieldTreeCell<String> cell = new TextFieldTreeCell<String>();
// 編集した文字列を、
// セルが持つデータに反映させるロジックを指定。
// 今回はテキストフィールドに入力した文字列を
// そのままセルが持つデータとして使うので、
// DefaultStringConverter を使用。
cell.setConverter(new DefaultStringConverter());
return cell;
});
}
use of javafx.scene.control.TreeView in project MiscellaneousStudy by mikoto2000.
the class TreeViewSample method start.
@Override
public void start(Stage stage) {
// ルート要素である TreeItem を作成
TreeItem<String> root = new TreeItem<String>("Root Node");
// ルートの子要素を作成
TreeItem<String> item1 = new TreeItem<String>("Item 1");
TreeItem<String> item2 = new TreeItem<String>("Item 2");
TreeItem<String> item3 = new TreeItem<String>("Item 3");
TreeItem<String> item4 = new TreeItem<String>("Item 4");
// item4 の子要素
TreeItem<String> item41 = new TreeItem<String>("Item 4-1");
TreeItem<String> item42 = new TreeItem<String>("Item 4-2");
TreeItem<String> item43 = new TreeItem<String>("Item 4-3");
// item4 に子要素を追加する
ObservableList<TreeItem<String>> image4tChildren = item4.getChildren();
image4tChildren.add(item41);
image4tChildren.add(item42);
image4tChildren.add(item43);
// ルート要素に子要素を追加する
ObservableList<TreeItem<String>> rootChildren = root.getChildren();
rootChildren.add(item1);
rootChildren.add(item2);
rootChildren.add(item3);
rootChildren.add(item4);
// 子を持つノードを開く
root.setExpanded(true);
item4.setExpanded(true);
// TreeView にルート要素を指定しながらインスタンス化
TreeView<String> treeView = new TreeView<String>(root);
// シーン作成
Scene scene = new Scene(treeView);
stage.setScene(scene);
stage.setTitle("Tree View Sample");
stage.show();
}
Aggregations