我想在GroovyFX中将一个项的集合绑定到一个TableView,但是我不想在调用tableView()之后更新表。
我可以在JavaFX中更新表,但不能在GroovyFX中更新。我猜有一些绑定丢失了。
代码是
import static groovyx.javafx.GroovyFX.start
import groovyx.javafx.beans.FXBindable;
import javafx.scene.control.TableView
class Command {
@FXBindable String command
@FXBindable String target
@FXBindable String value
}
start{
TableView scriptTable
ObservableList<Command> script = []
stage(title: 'Example for Stackoverflow', visible: true) {
scene(fill: groovyblue, width: 600, height: 250) {
borderPane{
center(align: CENTER){
script.add( new Command(command: "a", value: "b", target: "c") )
scriptTable = tableView(items: script, editable: true){
tableColumn(text: "Command", property: "command"){}
tableColumn(text: "Target", property: "target"){}
tableColumn(text: "Value", property: "value"){}
}
script.add( new Command(command: "d", value: "e", target: "f") )
}
}
}
}在这个例子中,我得到一个包含"a,b,c“的单行。

在表创建之后如何用数据("d,e,f")更新表的帮助是很有帮助的。
非常感谢。
发布于 2016-01-12 12:25:46
我认为其中一个问题可能是这行代码:
ObservableList<Command> script = []因为对于def someList = new ArrayList()来说,def someList = []是Groovy。
相反,您可能希望使用以下代码对其进行初始化:
ObservableList<Command> script = FXCollections.observableArrayList()它创建了实际的ObservableList
https://stackoverflow.com/questions/33655530
复制相似问题