0
我有一个具有SimpleStringProperty类型的变量的类。当这个类通过使用像这样的无参数构造函数初始化时:Foo f = new Foo();
,那么SimpleStringProperty变量不会被初始化。因此,我必须像这样初始化那个实例:Foo f = new Foo(null, null);
初始化仅具有属性类型变量的类的实例。 JavaFX
但是,有没有其他简单/干净的方法来初始化这些类的实例?我也试图扩展的类是这样的:
public class Foo extends StringPropertyBase{//...}
,
,但仍然没有参数的构造函数不初始化的变量。
Foo.java
public class Foo{
private SimpleStringProperty x;
private SimpleStringProperty y;
public Foo(String a, String b){
this.x = new SimpleStringProperty(a);
this.x = new SimpleStringProperty(b);
}
public StringProperty xProperty(){return x;}
public StringProperty yProperty(){return y;}
//...
}
谢谢!我应该想到这个.. – Vaib