2011-12-05 30 views
1

我有2個問題。我試圖用ListView創建一個垃圾。 Now here's how I want my UI to lookJavaFX 1.3:使用ListView的CRUD

我用下面的代碼創建了這一點:

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. 如何訪問保存按鈕操作中的「文本」變量?或任何其他變量(如選定的ComboBox)?我嘗試在ListView之外定義ListCell,並且通常定義ListView之外的所有內容,以便我可以輕鬆使用所有內容,但出現一些錯誤,說有些內容已經定義。

基本上對於第二個問題,我只是想知道如何填寫ListView以不同的方式,然後我現在正在做。

我在谷歌機器上沒有發現任何東西。如果有人可以幫助,我會很感激!

回答