JavaFX TableView does not display content

I am trying to insert some values ​​into the TableView, but it does not display the text in the columns, although they are not empty, because there are three rows (the same number of elements that I inserted into the TableView) that can be clicked.

I can select raws, but I do not see them

I have a ClientiController class, which is a fxml file controller, and this is a TableView declaration and tableView columns.

@FXML // fx:id="clientitable"
private TableView clientitable; // Value injected by FXMLLoader

@FXML // fx:id="nome"
private TableColumn nome; // Value injected by FXMLLoader

@FXML // fx:id="id"
private TableColumn id; // Value injected by FXMLLoader

@FXML // fx:id="telefono"
private TableColumn telefono; // Value injected by FXMLLoader

I call the initialize () method as the loadTable () function, which adds content to the TableView.

loadTable is in the same "ClientiController" class, and this is its implementation:

    @FXML
void loadTable()
{
    //Cliente
    try {
        List<String> clienti = (List<String>) fc.processRequest("ReadClienti");
        ObservableList<String> clienteData = FXCollections.observableArrayList(clienti);

        id.setCellValueFactory(new PropertyValueFactory<Cliente, String>("id"));
        nome.setCellValueFactory(new PropertyValueFactory<Cliente, String>("nome"));
        cognome.setCellValueFactory(new PropertyValueFactory<Cliente, String>("cognome"));
        telefono.setCellValueFactory(new PropertyValueFactory<Cliente, String>("n_tel"));


        System.out.println(clienteData);
        clientitable.setItems(clienteData);

        } catch (SecurityException | NoSuchMethodException
            | ClassNotFoundException | InstantiationException
            | IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
}

In the class Cliente, I have the following lines:

private String id, nome, cognome, n_tel;

get set String, . readAll (ReadClienti). List<Cliente> clienti loadTable() readAll, ArrayList<ArrayList<String>>.

raw ( ), ,

ArrayList<String> person =  (ArrayList<String>) clientitable.getSelectionModel().getSelectedItem();
System.out.println(person); 

, , , , .

SimpleStringProperty, , .

tableView ?

Edit: ,

            List<String> clienti = (List<String>) fc.processRequest("ReadClienti");

loadTable(), ArrayList<ArrayList<String>> List<String>. ObservableList<String>, ListView, ArrayLists . ArrayList<ArrayList<String>> ObservableList?

+4
1

"" . . getter setter , .
:

private String Clienteid;
private String ClienteName;

public getClientid(){
    return Clienteid;
}

...

id.setCellValueFactory(new PropertyValueFactory<Cliente, String>("id"));
nome.setCellValueFactory(new PropertyValueFactory<Cliente, String>("nome"));
0

Source: https://habr.com/ru/post/1608054/


All Articles