1

Im become crazy. Really don't know what happend with my code. I've tried this code and similar online-help but nothing helped me. My TableView do not show anything and really don't know whats is the problem.

Result of execution: Table with columns but with 0 row data (must be one).

Basic controller code :

@FXML
private TableView<Dato> tabla;
@FXML
private TableColumn<Dato, String> colNumero;
@FXML
private TableColumn<Dato, String> colEntidad;
@FXML
private TableColumn<Dato, String> colUsuario;
@FXML
private TableColumn<Dato, String> colPassword;
@FXML
private TableColumn<Dato, String> colComentarios;

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
    nuevaEntrada = false;

    colNumero.setCellValueFactory(new PropertyValueFactory<Dato, String>(
            "Num"));
    colEntidad.setCellValueFactory(new PropertyValueFactory<Dato, String>(
            "Entidad"));
    colUsuario.setCellValueFactory(new PropertyValueFactory<Dato, String>(
            "Usuario"));
    colPassword.setCellValueFactory(new PropertyValueFactory<Dato, String>(
            "Password"));
    colComentarios
            .setCellValueFactory(new PropertyValueFactory<Dato, String>(
                    "Comentarios"));
    buildData();

}

private ObservableList<Dato> data;

public void buildData() {

    data = FXCollections.observableArrayList();

    Dato dato = new Dato(1, "First", "First", "First", "First");
    data.add(dato);
    System.out.println(dato.toString());

    tabla.setItems(data);
}

Dato's class:

package application;

import javafx.beans.property.SimpleStringProperty;

public class Dato {
    private SimpleStringProperty num;
    private SimpleStringProperty entidad;
    private SimpleStringProperty usuario;
    private SimpleStringProperty password;
    private SimpleStringProperty comentarios;

    public Dato(int num, String entidad, String usuario, String password,
            String comentarios) {

        this.num = new SimpleStringProperty(Integer.toString(num));
        this.entidad = new SimpleStringProperty(entidad);
        this.usuario = new SimpleStringProperty(usuario);
        this.password = new SimpleStringProperty(password);
        this.comentarios = new SimpleStringProperty(comentarios);
    }

    public Dato(int num) {

        this.num = new SimpleStringProperty(Integer.toString(num));
    }

    protected SimpleStringProperty getNum() {
        return num;
    }

    protected SimpleStringProperty getEntidad() {
        return entidad;
    }

    protected SimpleStringProperty getUsuario() {
        return usuario;
    }

    protected SimpleStringProperty getPassword() {
        return password;
    }

    protected SimpleStringProperty getComentarios() {
        return comentarios;
    }
}
SerCrAsH
  • 440
  • 5
  • 14
  • I just replace the getter methods `protected SimpleStringProperty getNum()` with `protected String getNum(){ return num.get();}` and now num is a String (not an int). Same result, empty rows of data. – SerCrAsH Feb 08 '14 at 03:10
  • 1
    Solved by [link](http://stackoverflow.com/questions/17035478/javafx-propertyvaluefactory-not-populating-tableview) . The problem was the Dato's class. – SerCrAsH Feb 08 '14 at 03:45

0 Answers0