本文整理匯總了Java中javafx.scene.control.TreeView.setCellFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeView.setCellFactory方法的具體用法?Java TreeView.setCellFactory怎麽用?Java TreeView.setCellFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.TreeView
的用法示例。
在下文中一共展示了TreeView.setCellFactory方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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());
}
});
}
示例3: 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);
}
示例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);
}
示例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);
}
示例6: FxControlsTreeItem
import javafx.scene.control.TreeView; //導入方法依賴的package包/類
public FxControlsTreeItem(TreeView<Node> tv) {
this.tv = tv;
tv.setCellFactory(param -> {
TreeCell<Node> treeCell = new TextFieldTreeCell<Node>(new StringConverter<Node>() {
@Override
public String toString(Node n) {
return getName(n);
}
@Override
public Node fromString(String string) {
return null;
}
});
return treeCell;
});
}
示例7: 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();
}
示例8: setTreeView
import javafx.scene.control.TreeView; //導入方法依賴的package包/類
public void setTreeView(TreeView treeView) {
this.treeView = treeView;
treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>() {
@Override
public TreeCell call(TreeView<String> param) {
return new DnDCell(param);
}
});
}
示例9: 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;
}
示例10: setObject
import javafx.scene.control.TreeView; //導入方法依賴的package包/類
@Override
public void setObject(Subformula treedecomp, Consumer<Boolean> submitPossible) {
this.getChildren().clear();
if (treedecomp == null)
return;
TreeItem root = new TreeItem("root");
fillTreeView(root, treedecomp);
root.setExpanded(true);
TreeView treeView = new TreeView(root);
treeView.setStyle("-fx-accent: #c7e1ff");
treeView.setCellFactory(tv -> new Cell());
treeView.getSelectionModel()
.selectedItemProperty()
.addListener((ObservableValue observable, Object oldValue, Object newValue) -> {
TreeItem selectedItem = (TreeItem) newValue;
Subformula subformula = (Subformula) selectedItem.getValue();
structurePane.clearSelection();
structurePane.selectAll(subformula.validVertices);
structurePane.clearAnnotations();
for (Vertex v : (Set<Vertex>) structurePane.getStructure().getVertices()) {
String assignment = subformula.getVertexAssignment(v);
if (!assignment.equals(""))
structurePane.annotate(v, assignment);
}
});
ColumnConstraints columnConstraints = new ColumnConstraints();
columnConstraints.setPercentWidth(100);
this.getColumnConstraints().add(columnConstraints);
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setPercentHeight(100);
this.getRowConstraints().add(rowConstraints);
this.add(treeView, 0, 0);
}
示例11: 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;
}
示例12: createContent
import javafx.scene.control.TreeView; //導入方法依賴的package包/類
@Override
public Node createContent() {
// MasterDetailPane pane = new MasterDetailPane();
dataEditor.reset();
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.HORIZONTAL);
TreeView<Data> tree = new TreeView<>();
tree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
tree.setCellFactory(param -> new DataTextFieldTreeCell<>(data->data,null));
tree.setShowRoot(false);
SplitPane.setResizableWithParent(tree, Boolean.FALSE);
splitPane.getItems().add(tree);
Node dataEditorWidget = this.dataEditor.createContent();
SplitPane.setResizableWithParent(dataEditorWidget, Boolean.TRUE);
splitPane.getItems().add(dataEditorWidget);
splitPane.setDividerPositions(dividerPosition);
tree.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue!=null){
dataEditor.edit(newValue.getValue());
dataEditor.resetHistory();
}
});
dataTreeView.setUpdateAction(dataTreeItem -> {
tree.setRoot(dataTreeItem);
for (TreeItem<Data> treeItem: treeTraverser.breadthFirstTraversal(dataTreeItem)){
if (treeItem.getValue()==dataEditor.editData().get()){
tree.getSelectionModel().select(treeItem);
}
}
});
dataTreeView.update();
return splitPane;
}