0

項目のコレクションを 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") で更新する方法について、ヘルプをいただければ幸いです。

どうもありがとう。

4

1 に答える 1

0

問題の 1 つは、次のコード行にある可能性があると思います。

ObservableList<Command> script = []

なぜならdef someList = []Groovy for def someList = new ArrayList().

代わりに、次のコードで初期化することをお勧めします。

ObservableList<Command> script = FXCollections.observableArrayList()

実際のObservableList

于 2016-01-12T04:25:46.353 に答える