2016-09-16 98 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*/; 
}