I want to set focus on PropertySheet.Item
Node (for example TextField
) in ControlsFX. PropertySheet Item have unique name, so i can find PropertySheet.Item
with code propertySheet.getItems().get(i).getName()
. But there is no API to get Node
which corresponds to property item. The only solution i see is to walk scene graph with method getChildrenUnmodifiable
. But when i traverse PropertySheet
with this method it returns:
PropertySheet@1ab0e7e0[styleClass=property-sheet]
BorderPane@46e1b462
ToolBar@93ba99a[styleClass=tool-bar]
SegmentedButton@d5c968[styleClass=segmented-button]
HBox@1c3283db
ToggleButton@2fffaccc[styleClass=toggle-button left-pill]''
I don't get any Propertysheet Nodes such as TextField
or ComboBox
. Is it possible to do it? Thank you.
I found a solution.
You must use setPropertyEditorFactory
and global hashmap variable which will store all Nodes, so you can access it later. Sample code below.
public Map<String, Node> nodes = new HashMap<>();
SimpleObjectProperty<Callback<PropertySheet.Item, PropertyEditor<?>>> propertyEditorFactory =
new SimpleObjectProperty<>(this, "propertyEditor", new DefaultPropertyEditorFactory());
propertySheet.setPropertyEditorFactory((PropertySheet.Item param) -> {
PropertyEditor node = propertyEditorFactory.get().call(param);
nodes.put(uniquePropertyName, node.getEditor());
return node;
});
After this you can focus property Node with:
nodes.get(propertyName).requestFocus();