I am trying to add some values to a TableView, but even thought the ObservableList obsEvts
updates and has the values it should have, they are not correctly assigned to the TableView.
I tryed a lot of things, saw a lot of videos, tutorials, questions here, none of them solved my problem.
My whole code it right here: https://github.com/Skwead/Agenda/tree/bugs
My problem is in the Controller
class only, in these lines: https://github.com/Skwead/Agenda/blob/efbb594e1ce77fb1e721bc90b0429e719ec87aef/src/sample/Controller.java#L61
public class Controller implements Initializable{
@FXML private TableView<SkEvent> todayTable = new TableView<>();
@FXML private TableColumn<SkEvent, Date> horaTodoCol = new TableColumn<>();
@FXML private TableColumn<SkEvent, String> estadoTodoCol = new TableColumn<>();
@FXML private TableColumn<SkEvent, String> tarefaTodoCol = new TableColumn<>();
public void setupEvts(){
ObservableList<SkEvent> obsEvts = FXCollections.observableArrayList(calendarHandler.getToday());
horaTodoCol.setCellValueFactory(new PropertyValueFactory<SkEvent, Date>("date"));
tarefaTodoCol.setCellValueFactory(new PropertyValueFactory<SkEvent, String>("name"));
todayTable.setItems(obsEvts);
todayTable.getColumns().addAll(horaTodoCol, estadoTodoCol ,tarefaTodoCol);
todayTable.getColumns().set(0, horaTodoCol);
todayTable.getColumns().set(2, tarefaTodoCol);
}
}
public class CalendarHandler {
private List<SkEvent> sortedEvts = new ArrayList<>();
public ArrayList<SkEvent> getToday(){
ArrayList<SkEvent> todaySchedule = new ArrayList<>();
for (SkEvent event : sortedEvts) {
if (event.getDate().getDay() == (new Date(LocalDateTime.now().getYear(), LocalDateTime.now().getMonthValue(),
LocalDateTime.now().getDayOfMonth()).getDay())) {
todaySchedule.add(event);
}
}
Collections.sort(todaySchedule, Comparator.comparing(SkEvent::getDate));
return todaySchedule;
}
No error is shown, at the end of this method call the todatTable
should have all the data in obsEvts
.