简体   繁体   中英

How can I add items from an ArrayList to a TableCloum using an FXML file? ~JavaFX

I wonder if there is an option to add the Sting name = "xy" to a TableColumn from a TableView .

My program updates the ArrayList frequently, so I want to delete all the items out of the TableColumn and add the String variable name to the TableCloumn .

I set up my program with JavaFX Scene Builder. My table has the fixed id: cardsTable and my Colum had the id cardsColumn.

Any advice?

You can not add variables to the table in fxml, you can only add columns and their names.

<TableView fx:id="table">
    <columns>
      <TableColumn fx:id="test1" editable="false" prefWidth="75.0" text="Test1" />
      <TableColumn fx:id="test2" editable="false" prefWidth="75.0" text="Test2" />
        <TableColumn fx:id="test3" editable="false" prefWidth="75.0" text="Test3" />
        <TableColumn fx:id="test4" editable="false" prefWidth="75.0" text="Test4" />
        <TableColumn fx:id="test5" editable="false" prefWidth="75.0" text="Test5" />
    </columns>
  </TableView>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM