Why does my table show the values in this way?

1

It should be noted that what I want to do is that the table shows the data when the "Start" button is clicked.

link

package simulador;


import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.SimpleDoubleProperty;

public class Proceso {
    public SimpleIntegerProperty id = new SimpleIntegerProperty();
    public SimpleStringProperty nombre = new SimpleStringProperty();
    public SimpleIntegerProperty quantum = new SimpleIntegerProperty();
    public SimpleDoubleProperty recursos = new SimpleDoubleProperty();
    public SimpleStringProperty estado = new SimpleStringProperty();
    public SimpleIntegerProperty tiempo = new SimpleIntegerProperty();

public SimpleIntegerProperty getId() {
    return id;
}
public SimpleStringProperty getNombre() {
    return nombre;
}
public SimpleIntegerProperty getQuantum() {
    return quantum;
}
public SimpleDoubleProperty getRecursos() {
    return recursos;
}
public SimpleStringProperty getEstado() {
    return estado;
}
public SimpleIntegerProperty getTiempo() {
    return tiempo;
}
}

    public class FXMLDocumentController implements Initializable {



    @FXML private TableView <Proceso> tablaInfo;
    @FXML private TableColumn columnaId;
    @FXML private TableColumn columnaNombre;
    @FXML private TableColumn columnaQuantum;
    @FXML private TableColumn columnaRecursos;
    @FXML private TableColumn columnaEstado;
    @FXML private TableColumn columnaTiempo;

    public ObservableList<Proceso> lista;    


    @FXML
    private void botonIniciarClicked(ActionEvent event) {
        for (int i = 1 ; i < 11 ; i++){
            int Q = (int)((Math.random()*29)+1);
            Proceso proceso = new Proceso();
            proceso.id.set(i);
            proceso.nombre.set("Proceso " + i);
            proceso.quantum.set(Q);
            proceso.recursos.set(1);
            proceso.estado.set("Ejecutando");
            proceso.tiempo.set(1);
            lista.add(proceso);           
        }


    }
    private void iniciarTabla(){
        columnaId.setCellValueFactory(new PropertyValueFactory<Proceso,Integer>("id"));
        columnaNombre.setCellValueFactory(new PropertyValueFactory<Proceso,String>("nombre"));
        columnaQuantum.setCellValueFactory(new PropertyValueFactory<Proceso,Integer>("quantum"));
        columnaRecursos.setCellValueFactory(new PropertyValueFactory<Proceso,Double>("recursos"));
        columnaEstado.setCellValueFactory(new PropertyValueFactory<Proceso,String>("estado"));
        columnaTiempo.setCellValueFactory(new PropertyValueFactory<Proceso,Integer>("tiempo"));

        lista = FXCollections.observableArrayList();
        tablaInfo.setItems(lista);

    }
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        this.iniciarTabla();


    }    

}
    
asked by Gabo Reyes 09.04.2017 в 01:00
source

2 answers

0

You have to modify your class to be able to access the values correctly by defining the accessors:

    public class Proceso {
        public SimpleIntegerProperty id = new SimpleIntegerProperty();
        public SimpleStringProperty nombre = new SimpleStringProperty();
        public SimpleIntegerProperty quantum = new SimpleIntegerProperty();
        public SimpleDoubleProperty recursos = new SimpleDoubleProperty();
        public SimpleStringProperty estado = new SimpleStringProperty();
        public SimpleIntegerProperty tiempo = new SimpleIntegerProperty();

    public Integer getId() {
        return id.get();
    }

    public void setId(Integer newValue) {
        return id.set(newValue);
    }

    public SimpleIntegerProperty getId() {
        return id;
    }


    public String getNombre() {
        return nombre.get();
    } 

    public void setNombre(String newValue) {
        return nombre.set(newValue);
    }

    public SimpleStringProperty getNombre() {
       return nombre;
    }

...
...
...
 }
    
answered by 09.04.2017 в 02:01
0

Fields are not objects that your tablet recognizes then shows it from which type it is you have to change it to string or int types if it shows

    
answered by 09.04.2017 в 05:13