:
/**
* 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);
}
당신이 편집기에 리스너를 추가 할 수 있습니다 PropertyEditor를에 콜백을 만드는 경우. 예를 들어
:
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;
};
}
감사합니다. 예제 코드를 테스트했지만 나에게 적합하지 않다. PropertyItemBase를 이해하지 못합니다. PropertySheet.Item이 될 수 없습니다. 맞습니까? 그 메소드에는 setEditor() 메소드가 없기 때문에. 그럼, 뭐지? @bonfatti – user6839234
코드를 붙여 넣기 전에 itemBase 부분을 제거하려고했습니다. 죄송합니다. PropertyItemBase는 Editor 인스턴스와 getter 및 setter를 포함하는 PropertySheet.Item의 구현입니다. 내 대답을 편집하여 itemBase를 제거합니다. – bonfatti
대단히 감사합니다! – user6839234