3

Hi could you help me how I can do contours of the table. I want that all rows in table have contours .Thanks for help. My table look like this :

TableColumn busNumberCol = new TableColumn("Linia");
        busNumberCol.setCellValueFactory(
                new PropertyValueFactory<>("busNumber"));
        busNumberCol.setPrefWidth(tb.getPrefWidth()/5);

        TableColumn courseCol = new TableColumn("Kierunek");
        courseCol.setCellValueFactory(
                new PropertyValueFactory<>("nameBusStpo"));
        courseCol.setPrefWidth((tb.getPrefWidth()-tb.getPrefWidth()/5)/2-1);
        TableColumn departureCol = new TableColumn("Odjazd");
        departureCol.setPrefWidth((tb.getPrefWidth()-tb.getPrefWidth()/5)/2-1);
        departureCol.setCellValueFactory(
                new PropertyValueFactory<>("busTimetable"));
        table.setPrefHeight(tb.getPrefHeight());

        table.setStyle("-fx-background-color: orange");
        table.setPrefWidth(tb.getPrefWidth());
        table.setItems(list);
        table.getColumns().addAll(busNumberCol, courseCol, departureCol);
        table.setPlaceholder(new Label(""));    
Krzysztof Pokrywka
  • 1,356
  • 4
  • 27
  • 50
  • 1
    Add this class selector to you stylesheet: `.table-row-cell { -fx-background-color: blue, -fx-background; }`. The result should be horizontal blue lines. – DVarga Sep 16 '16 at 13:02

2 Answers2

1

try this in the css(for me is working):

.table-row-cell{
    -fx-background-color: -fx-table-cell-border-color, /*coloryouwant*/;
}
Maglioni Lorenzo
  • 358
  • 1
  • 12
1

You can use:

.table-row-cell{
      -fx-border-color:red;
      -fx-border-width:1.0;
      /* -fx-background-color */
    }

Mention that it this adds a border around every row.For background color you can uncomment the above with /* -fx-background-color*/

Also

For more styling on TableView look Change JavaFX TableView font size

Community
  • 1
  • 1
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93