Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1.     @FXML
  2.     TableView<Statistics> tableView;
  3.     @FXML
  4.     TableColumn<Statistics, Integer> colWeekNumber;
  5.     @FXML
  6.     TableColumn<Statistics, Double> colExerciseHours;
  7.  
  8.  
  9.  
  10. public class HandleStatistics {
  11.  
  12.     public void addStatistics(TableView<Statistics> tableView, TableColumn<Statistics, Integer> colWeekNumber, TableColumn<Statistics, Double> colExerciseHours) {
  13.         colWeekNumber.setCellValueFactory(new PropertyValueFactory<Statistics, Integer>("weekNumber"));
  14.         colExerciseHours.setCellValueFactory(new PropertyValueFactory<Statistics, Double>("exerciseHours"));
  15.  
  16.         tableView.setItems(getStatistics());
  17.     }
  18.  
  19.     public ObservableList<Statistics> getStatistics() {
  20.         ObservableList<Statistics> statistics = FXCollections.observableArrayList();
  21.         statistics.add(new Statistics(46, 4.6));
  22.         statistics.add(new Statistics(47, 5.8));
  23.  
  24.         return statistics;
  25.     }
  26.  
  27.  
  28. package Functionality;
  29.  
  30. public class Statistics {
  31.  
  32.     private int weekNumber;
  33.     private double exerciseHours;
  34.  
  35.     public Statistics(int weekNumber, double exerciseHours) {
  36.         this.weekNumber = weekNumber;
  37.         this.exerciseHours = exerciseHours;
  38.     }
  39.  
  40.     public void setWeekNumber(int weekNumber) {
  41.         this.weekNumber = weekNumber;
  42.     }
  43.  
  44.     public int getWeekNumber() {
  45.         return weekNumber;
  46.     }
  47.  
  48.     public void setExerciseHours(double exerciseHours) {
  49.         this.exerciseHours = exerciseHours;
  50.     }
  51.  
  52.     public double getExerciseHours() {
  53.         return exerciseHours;
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement