I have a tableview which stores data, and works just fine except I can't seem to get the horizontal gridlines to be visible. I've tried what was suggested here and it's not working for me. I've looked around and haven't been able to find any other suggestions for this issue.
CSS:
.column-header-background {
visibility: hidden; -fx-padding: -1em;
}
.table-view {
-fx-table-cell-border-color: black;
}
.table-view .table-row-cell {
-fx-border-width: 1;
}
Cell Factory:
public class StitchCell extends TableCell<ObservableList<Stitch>, Color> {
@Override
protected void updateItem(Color color, boolean empty) {
super.updateItem(color, empty);
int r = (int) (color.getRed() * 255);
int g = (int) (color.getGreen() * 255);
int b = (int) (color.getBlue() * 255);
if (empty || color == null) {
this.setStyle("-fx-background-color: white");
} else {
this.setStyle("-fx-background-color: rgb(" + r + "," + g + "," + b + ")");
}
}
}
Table creation:
protected TableView<ObservableList<Stitch>> call() throws Exception {
pattern.setItems(stitchList);
for (ObservableList<Stitch> row : stitchList) {
for (int i= pattern.getColumns().size(); i<row.size(); i++){
TableColumn<ObservableList<Stitch>, Color> column = new TableColumn<>();
final int columnIndex = i ;
column.setCellValueFactory( rowData ->
rowData.getValue() // the row value, i.e. an ObservableList<Stitch>
.get(columnIndex) // the Stitch for this cell
.getDisplayColorProperty() );
column.setCellFactory(col -> new StitchCell());
column.setEditable(true);
column.setMinWidth(5);
column.setPrefWidth(5);
column.setMaxWidth(5);
pattern.getColumns().add(column);
}
}
pattern.setFixedCellSize(5);
pattern.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
pattern.getSelectionModel().setCellSelectionEnabled(true);
return pattern;
} // End Call
Thanks in advance!