0
votes

I'm currently trying to allow for a TableView to be a user input source, and in trying to read through tutorials and the like, I'm having a hard time grasping what needs to be done simply to allow population of the table by the user.

Almost every example I see overrides everything, where as the TableCells themselves have a setEdit() method, of which I cannot ascertain how to reference a TableCell itself to call the method.

However, I'm having a hard time working in the reverse direction, and I'm not finding the tutorials very informative of what's going on, only huge amounts code to make something that seems fundamentally simple to get working.

The solution I need only needs to be able to alter string data inside of a cell, does is it really necessary to override every step of the process to just click a cell, have it toggle to editable state, take a string, and then return to a label with text as the string entered?

Also, I'm doing this by FXML, if that makes a difference.

1
Does TextFieldTableCell not meet your needs? - James_D
It would, in theory, buy how do I cause the table to be built out of those rather than labels? - Captain Prinny
In Java, myTableColumn.setCellFactory(TextFieldTableCell.forTableColumn());. In FXML (I've never tried this approach) <TableColumn><cellFactory><TextFieldTableCell fx:factory="forTableColumn"/></cellFactory></TableColumn> - James_D
I knew there had to be a simple solution, why is it that all the tutorials have a minimum of 100 lines of code? I've been looking for this solution for like a week. - Captain Prinny
works, was a problem with the output from Scene Builder - Captain Prinny

1 Answers

0
votes

Problem stemmed from Scene Builder defaulting the Table Columns to not being editable, despite the table being editable.

Java

myTableColumn.setCellFactory(TextFieldTableCell.forTableColumn());

FXML

<TableColumn>
    <cellFactory>
        <TextFieldTableCell fx:factory="forTableColumn"/>
    </cellFactory>
</TableColumn>