2016-09-16 59 views
3

嗨,你能幫助我如何做表格的輪廓。我希望表中的所有行都有輪廓。感謝您的幫助。我的表是這樣的:表格的JavaFX表格輪廓

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(""));  
+1

此類選擇添加到您的樣式表:'。錶行細胞{-fx背景色:藍色,-fx -背景; }'。結果應該是水平的藍線。 – DVarga

回答

1

您可以使用:

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

何況,它這增加了每一行周圍的邊框。對於背景顏色,您可以取消上述註釋/* -fx-background-color*/

而且

有關的TableView更多的樣式看起來Change JavaFX TableView font size

1

試試這個在CSS(對我來說是工作):

.table-row-cell{ 
    -fx-background-color: -fx-table-cell-border-color, /*coloryouwant*/; 
}