TableView:只显示一些列数据

时间:2018-01-11 15:07:59

标签: javafx tableview

所以我试图让一些TableViews工作,我已经设法让它们中的一些工作但是some of my columns' data is missing而且我不太明白让一些列出现的区别是什么别人没有。这是表格初始化的代码:

void initTables(TableView<Layer> layerTable, TableView<Section> sectionTable, TableView<Edge> edgeTable){

    // Columnas de tabla ejes
    TableColumn<Edge, Integer> indexEdgeCol = new TableColumn<>("Numero"); //Not showing up
    indexEdgeCol.setMaxWidth(80.);
    indexEdgeCol.setCellValueFactory(new PropertyValueFactory<Edge, Integer>("Id"));
    TableColumn<Edge, Double> sepEdgeCol = new TableColumn<>("Separación"); //Not showing up
    sepEdgeCol.setMinWidth(110.);
    sepEdgeCol.setCellValueFactory(new PropertyValueFactory<Edge, Double>("Separación"));
    TableColumn<Edge, Double> loadEdgeCol = new TableColumn<>("Carga");
    loadEdgeCol.setMinWidth(110.);
    loadEdgeCol.setCellValueFactory(new PropertyValueFactory<Edge, Double>("Carga"));

    edgeTable.setItems(getData().getEdges());

    // Columnas de tabla tramos
    TableColumn<Section, Integer> indexSectionCol = new TableColumn<>("Número");
    indexSectionCol.setMaxWidth(100.);
    indexSectionCol.setCellValueFactory(new PropertyValueFactory<Section, Integer>("Id"));
    TableColumn<Section, Double> lengthSectionCol = new TableColumn<>("Longitud"); //Not showing up
    lengthSectionCol.setMinWidth(120.);
    lengthSectionCol.setCellValueFactory(new PropertyValueFactory<Section, Double>("Longitud"));
    TableColumn<Section, Integer> slabSectionCol = new TableColumn<>("Num. Losas"); //Not showing up
    slabSectionCol.setMinWidth(125.);
    slabSectionCol.setCellValueFactory(new PropertyValueFactory<Section, Integer>("losas"));

    sectionTable.setItems(getData().getSections());

    // Columnas de tabla capas
    TableColumn<Layer, Integer>indexLayerCol = new TableColumn<>("ID");
    indexLayerCol.setMaxWidth(40.);
    indexLayerCol.setCellValueFactory(new PropertyValueFactory<Layer, Integer>("Id"));
    TableColumn<Layer, String>nameLayerCol = new TableColumn<>("Nombre");
    nameLayerCol.setMinWidth(130.);
    nameLayerCol.setCellValueFactory(new PropertyValueFactory<Layer, String>("Name"));
    TableColumn<Layer, Double> modYoungLayerCol = new TableColumn<>("Mod. de Young");
    modYoungLayerCol.setMinWidth(101.);
    modYoungLayerCol.setCellValueFactory(new PropertyValueFactory<Layer, Double>("Young"));
    TableColumn<Layer, Double> thickLayerCol = new TableColumn<>("Espesor");
    thickLayerCol.setMinWidth(101.);
    thickLayerCol.setCellValueFactory(new PropertyValueFactory<Layer, Double>("Espesor"));

    layerTable.setItems(getData().getLayers());

    edgeTable.getColumns().setAll(indexEdgeCol, sepEdgeCol, loadEdgeCol);
    sectionTable.getColumns().setAll(indexSectionCol, lengthSectionCol, slabSectionCol);
    layerTable.getColumns().setAll(indexLayerCol, nameLayerCol, modYoungLayerCol, thickLayerCol);
}

据我所知,数据是应该的,只是它没有显示在所述表中,我不知道我做错了什么,所以任何帮助都会受到赞赏。提前谢谢!

编辑:根据要求,这是我的SectionEdge类:

Section.java:

import java.util.ArrayList;

public class Section extends Object{

    private final int id;
    private int bloques; 
    private double length;

    public Section(int id, int bloques, double length) {
        super();
        this.id = id;
        this.bloques = bloques;
        this.length = length;
        // this.start = start;
        // end = length + start;
    }

    public int getId(){
        return id;
    }

    public int getBloques(){
        return bloques;
    }

    public void setBloques(int bloques){
        this.bloques = bloques;
    }

    public double getLength() {
            return length;
    }

    public void setLength(double longitud) {
            this.length = longitud;
    }

    @Override
    public String toString() {
        return "Section [id=" + id  + ", length=" + length + ", bloques=" + bloques + "]";
    }
}

Edge.java:

public class Edge extends Object{

    private final int index;
    private double sep;
    private double carga;

    public Edge(int index, double sep, double carga){
        this.index = index;
        this.sep = sep;
        this.carga = carga;
    }

    public int getIndex(){
        return index;
    }

    public void setSep(double s){
        sep = s;
    }

    public double getSep(){
        return sep;
    }

    public void setCarga(double c){
        carga = c;
    }

    public double getCarga(){
        return carga;
    }

    @Override
    public String toString() {
        return "Edge [index=" + index + ", separación=" + sep + ", carga=" + carga + "]";
    }
}

0 个答案:

没有答案