我有一个现有的类,我想对 javafx 一无所知。是否有一种普遍接受的方式来装饰或调整它以支持 javafx 属性?
我想做类似以下的事情(这显然是错误的):
public class FooWrapper {
/**
* Decorates a Foo instance with javafx stuff
*/
private final Foo foo;
public FooWrapper(Foo toWrap) {
this.foo = toWrap;
}
private final StringProperty name = new SimpleStringProperty();
public final StringProperty nameProperty() {
return this.foo.getName();//?????
}
public final String getName() {
return this.nameProperty().get();
}
public final void setFirstName(final String name) {
this.nameProperty().set(name);
}
}
public class Foo {
/**
* Basic class I want to keep ignorant of javafx
*/
private String name = "hello";
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
忽然笑
相关分类