JavaFX 1.3:使用ListView进行CRUD

时间:2011-12-05 21:28:16

标签: listview crud javafx

我有两个问题。我正在尝试使用ListView创建一个crud。 Now here's how I want my UI to look

我使用以下代码创建了它:

var studentManagementListView: ListView = ListView {
        items: ["bla", "bla", "bla", "bla", "bla", "bla", "bla", "bla", "bla", "bla", "bla"]
        cellFactory: function() {
            def listCell: ListCell = ListCell {
                        node: HBox {
                            spacing: 10
                            content: [
                                Label {
                                    text: bind if (listCell.empty) then "" else "{listCell.item}"
                                    visible: bind not listCell.selected and not listCell.empty
                                }
                                TextBox {
                                    text: bind listCell.item.toString()
                                    columns: 12
                                    visible: bind listCell.selected and not listCell.empty
                                    selectOnFocus: true
                                }
                                SwingComboBox {
                                    visible: bind listCell.selected and not listCell.empty

                                    items: for (classItem in classes) {
                                        SwingComboBoxItem {
                                            selected: false
                                            text: classItem.toString()
                                            value: classItem
                                        }
                                    }
                                }
                                Button {
                                    text: "delete"
                                    visible: bind listCell.selected and not listCell.empty
                                    action: function() {

                                    }
                                }
                                Button {
                                    text: "save"
                                    visible: bind listCell.selected and not listCell.empty
                                    action: function() {

                                    }
                                }
                            ]
                        }
                    }
        }
    };

现在我遇到了麻烦。

  1. SwingComboBox表现得非常奇怪,只有在新选择ListCell时才会打开。选择SwingComboBoxItem
  2. 也是不可能的
  3. 如何在保存按钮操作中访问“text”变量?或任何其他变量(如选定的ComboBox)?我尝试在ListView之外定义ListCell,并且通常定义ListView之外的所有内容,以便我可以轻松地使用所有内容,但我得到一些错误,说某些内容已经定义。
  4. 基本上对于第二个问题,我只想知道如何以不同的方式填充ListView然后我现在正在做。

    我还没有在谷歌机器上找到任何有用的东西。如果有人可以提供帮助,我会很感激!

1 个答案:

答案 0 :(得分:0)

我认为this link可能对您有帮助。