在TableView Javafx上为特定列添加样式

时间:2017-04-04 22:15:28

标签: css javafx tableview

我试图在程序启动时添加颜色。但我只想在前两行和特定列中添加它,这是我的初始化代码

public void initialize(URL location, ResourceBundle resources) {
    for (int i=0;i<28;i++){
        if (i == 0 || i == 1){
            listaPaginacion.add(new tablaPaginacion(i,"S.O.",0,"100","Ocupado"));
            tvTablaPaginacion.setItems(listaPaginacion);
            tcId.setCellValueFactory(new PropertyValueFactory<>("Id"));
            tcPagina.setCellValueFactory(new PropertyValueFactory<>("Pagina"));
            tcTam.setCellValueFactory(new PropertyValueFactory<>("Tam"));
            tcTam.getStyleClass().add(i,"so-colum");

            tcEstado.setCellValueFactory(new PropertyValueFactory<>("Estado"));
            tcNumeroMarco.setCellValueFactory(new PropertyValueFactory<>("NumeroMarco"));

        }else{
            listaPaginacion.add(new tablaPaginacion(i,"",0,"0","Libre"));
            tvTablaPaginacion.setItems(listaPaginacion);
            tcId.setCellValueFactory(new PropertyValueFactory<>("Id"));
            tcPagina.setCellValueFactory(new PropertyValueFactory<>("Pagina"));
            tcTam.setCellValueFactory(new PropertyValueFactory<>("Tam"));
            tcTam.getStyleClass().remove("so-colum");
            tcEstado.setCellValueFactory(new PropertyValueFactory<>("Estado"));
            tcNumeroMarco.setCellValueFactory(new PropertyValueFactory<>("NumeroMarco"));

        }


    }
}

我尝试先添加该类,然后将其删除但不起作用

0 个答案:

没有答案