Java ListProperty的逗号分隔字符串

Java ListProperty的逗号分隔字符串,java,javafx,listproperty,Java,Javafx,Listproperty,我必须编写方法,该方法将获取我的字符串(用逗号分隔小时),并返回字符串的ListProperty。 在我的构造函数中,我有 this.showingHour = new SimpleListProperty<String>(); this.showingHour=新的SimpleListProperty(); 我想使用本主题中的方法: List items=Arrays.asList(str.split(“\\s*,\\s*”); 但它会创建ArrayList。除了ListPr

我必须编写方法,该方法将获取我的字符串(用逗号分隔小时),并返回字符串的ListProperty。 在我的构造函数中,我有

this.showingHour = new SimpleListProperty<String>();
this.showingHour=新的SimpleListProperty();
我想使用本主题中的方法:

List items=Arrays.asList(str.split(“\\s*,\\s*”);
但它会创建ArrayList。除了ListProperty,还有这样的函数吗?

怎么样:

ListProperty<String> lp= new ListProperty<>();

lp.addAll(Arrays.asList(str.split("\\s*,\\s*")));
ListProperty lp=new ListProperty();
lp.addAll(Arrays.asList(str.split(“\\s*,\\s*”));
您可以这样做

    ListProperty<String> list = new SimpleListProperty<(
        FXCollections.observableArrayList(str.split("\\s*,\\s*")));

为您提供一个包含所需元素的可观察列表。

从哪一行-添加或创建?添加。我通过“getText”将字符串从其他方法中分离出来,我看到您有SimpleListProperty类。如何申报<代码>类SimpleListProperty然后呢<代码>扩展,
实现
?将整行粘贴到此处。SimpleListProperty是此列表的声明,与SimpleStringProperty和SimpleIntegerProperty等其他变量一样。这是一个类电影,我只导入javafx.beans.property.ListProperty和javafx.beans.property.SimpleListPropertyTanks,我必须将声明更改为
this.showingHour=new SimpleListProperty(FXCollections.observableList(new ArrayList())然后进行拆分
    ListProperty<String> list = new SimpleListProperty<(
        FXCollections.observableArrayList(str.split("\\s*,\\s*")));
FXCollections.observableArrayList(str.split("\\s*,\\s*"))