I m trying to change the representation of the rating column of my tableView ( please look at picture 1 )
into rating stars of jfoenix library for better representation
here is the code (in Controller) of my table view :
@FXML
public void initialize(URL url, ResourceBundle rb) {
nom_client.setCellValueFactory(new PropertyValueFactory<Review, String>("nom_client_review"));
date_review.setCellValueFactory(new PropertyValueFactory<Review, String>("date_review"));
descrip_review.setCellValueFactory(new PropertyValueFactory<Review, String>("description_review"));
rating.setCellValueFactory(new PropertyValueFactory<Review, Float>("rating"));
try {
ObservableList<Review> reviewlist = ReviewCrud.getAllRecords();
populateTable(reviewlist);
} catch (ClassNotFoundException ex) {
Logger.getLogger(AfficherReview2Controller.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(AfficherReview2Controller.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void populateTable(ObservableList<Review> reviewlist) {
reviewtable.setItems(reviewlist);
}
please note that i m not allowed to use simplefloatproperty, that why my rating in the Review class is set to float
below the code that i use to get data from my DB:
public static ObservableList<Review> getAllRecords() throws ClassNotFoundException, SQLException {
Connection cnnx = ReviewConnection.getInstance().getCnx();
String requete = "SELECT * FROM review_client ";
try {
Statement st = cnnx.createStatement();
ResultSet rs = st.executeQuery(requete);
ObservableList<Review> reviewList = getReviewObjects(rs);
return reviewList;
} catch (SQLException ex) {
System.err.println(ex.getMessage());
throw ex;
}
}
private static ObservableList<Review> getReviewObjects(ResultSet rs) throws ClassNotFoundException, SQLException {
try {
ObservableList<Review> reviewList = FXCollections.observableArrayList();
while (rs.next()) {
Review r = new Review();
r.setNom_client_review(rs.getString("nom_client_review"));
r.setDate_review(rs.getString("date_review"));
r.setDescription_review(rs.getString("description_review"));
r.setRating(rs.getFloat("rating"));
reviewList.add(r);
}
return reviewList;
} catch (SQLException ex) {
System.err.println(ex.getMessage());
throw ex;
}
}
my only goal is to convert the float values of the rating columns into stars of jfoenix
if anyone knows how please help me
will be very appreciated