1

Is there a convenice way to monitor the propertysheet item status? Like textfield get focused, boolean status change, etc.

I've looked the javadoc,did't find one.

And there's an issue here, but the solution seems to let the editor know the change of a property.

What I want is just in the opposite, monitor the editor.

Anyone can help?

1 Answers1

1

From PropertySheet:

/**
 * Sets a new editor factory used by the PropertySheet to determine which
 * {@link PropertyEditor} to use for a given {@link Item}.
 * @param factory 
 */
public final void setPropertyEditorFactory( Callback<Item, PropertyEditor<?>> factory ) {
    propertyEditorFactory.set( factory == null? new DefaultPropertyEditorFactory(): factory );
}

If you create a callback to a PropertyEditor you can add listeners to the editor.

For example:

    SimpleObjectProperty<Callback<PropertySheet.Item, PropertyEditor<?>>> propertyEditorFactory = new SimpleObjectProperty<>(this, "propertyEditor", new DefaultPropertyEditorFactory());
    projectSheet.setPropertyEditorFactory(getItemPropertyEditorCallback(propertyEditorFactory));



private Callback<PropertySheet.Item, PropertyEditor<?>> getItemPropertyEditorCallback(SimpleObjectProperty<Callback<PropertySheet.Item, PropertyEditor<?>>> propertyEditorFactory) {
    return param -> {
        PropertyEditor<?> editor = propertyEditorFactory.get().call(param);

        //Add listeners to editor
        editor.getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> System.out.println(newValue));

        return editor;
    };
}
bonfatti
  • 71
  • 6
  • Thank you. I have tested the example code,but not working for me. I don't understand the PropertyItemBase, it can't be a PropertySheet.Item, right? Because there isn't a setEditor() method in its methods. So, what is it? @bonfatti – user6839234 Mar 25 '17 at 12:17
  • I've meant to remove the itemBase part of the code before pasting it my comment, sorry about that. The PropertyItemBase is an implementation of the PropertySheet.Item containing a instance of the editor, plus getter and setter. I will edit my answer to remove the itemBase. – bonfatti Mar 26 '17 at 13:11