Basically you will have to implement a dayCellFactory, this will allow you to manipulate how calendar cells will be rendered. Example of commented documentation:
DatePicker dp = new DatePicker();
dp.setDayCellFactory(new Callback<DatePicker, DateCell>() {
@Override
public DateCell call(DatePicker arg0) {
return new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
// Chamada obrigatória ao renderizador da superclasse
super.updateItem(item, empty);
// Aqui estamos trocando a cor do background de um dia específico
if(MonthDay.from(item).equals(MonthDay.of(9, 15))) {
setStyle("-fx-background-color: #ff4444;");
}
// Aqui estamos desabilitando a data do dia seguinte
if(item.equals(LocalDate.now().plusDays(1))) {
setDisable(true);
}
}
};
}
});
It stays like this after the execution:
Using this logic you can implement a class called Event, with a Localdate and a description as attributes, and traverse an array of events within the Factory by painting them accordingly.
Already the question of Popup you can use the method setTooltip that this component inherits from the Control class (The tooltip is a bit buggy). Or you can use the Popover Controlsfx, a well-known library of custom components for Javafx.
About date/calendar related components: Javafx has the
DatePicker
, do not need to use any third party. You can use the methods to color days with scheduled events and the "click" event to find the scheduled event on a given day.– Renan Gomes
I will try to use Datepicker, but could you point me some links with good examples, or could you elaborate some?
– Paulo Amosse