JavaFX将StringProperty[值:“";]迁移到简单字符串
如何将StringProperty转换为String?我只需要文本值。 但我的函数是show给我看“StringProperty[value:bbbbbb]” 我知道JavaFX特定的访问器语法和访问器。但我不明白该怎么说才对JavaFX将StringProperty[值:“";]迁移到简单字符串,java,javafx,Java,Javafx,如何将StringProperty转换为String?我只需要文本值。 但我的函数是show给我看“StringProperty[value:bbbbbb]” 我知道JavaFX特定的访问器语法和访问器。但我不明白该怎么说才对 public class TestDelete { private static StringProperty myTestValue = new SimpleStringProperty(); public static void main(String[] arg
public class TestDelete {
private static StringProperty myTestValue = new SimpleStringProperty();
public static void main(String[] args) {
setText();
}
private static void setText() {
TestDelete testDelete = new TestDelete();
String myText = "aaaaa bbbbbb";
myTestValue = new SimpleStringProperty(myText.replaceAll(".* ", ""));
System.out.println(myTestValue);
}
public void getmyTestValue() {
myTestValue.get();
}
public void setmyTestValue(String newVal) {
myTestValue.set(newVal);
}
public StringProperty myTestValueProperty() {
return myTestValue;
}
}简单字符串属性的作用如下
public class NewBean {
SimpleStringProperty id = new SimpleStringProperty();
SimpleStringProperty name = new SimpleStringProperty();
public NewBean(){
}
public String getId() {
return id.get();
}
public SimpleStringProperty idProperty() {
return id;
}
public void setId(String id) {
this.id.set(id);
}
public String getName() {
return name.get();
}
public SimpleStringProperty nameProperty() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
}
System.out.println(myTestValue.get())
?谢谢。我会试着把它抛给弦,你不需要抛给弦StringProperty.get()
已经返回了一个String
。现在开始学习javafx基础教程,即属性;)