0

I'm using JavaFx with the jfxtras library. I included the "Agenda" control into my fxml and it is correctly rendered on the page. Unfortunately, the associated appointments are not displayed on the table and there are no events associated on it. How can I achieve the same behavior of the samples? Where could I find a tutorial on this control? Here the java code:

   LocalDate lTodayLocalDate = LocalDate.now();
   Agenda.Appointment[] lTestAppointments = new Agenda.Appointment[]{
       new Agenda.AppointmentImpl()
           .withStartTime(new GregorianCalendar(lTodayLocalDate.getYear(), lTodayLocalDate.getMonthValue(), lTodayLocalDate.getDayOfMonth(), 4, 00))
           .withEndTime(new GregorianCalendar(lTodayLocalDate.getYear(), lTodayLocalDate.getMonthValue(), lTodayLocalDate.getDayOfMonth(), 5, 30))
           .withSummary("A")
           .withDescription("A much longer test description")
           .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
   };
   agenda.appointments().addAll(lTestAppointments);
Merecol
  • 7
  • 1
  • 5

1 Answers1

0

Yeah, no tutorial needed, this mistake everybody makes once in a while; you're using the month provided by LocalDate to create a Calendar. However, LocalDate's month runs from 1 to 12, Calendar's from 0 to 11, so the appointment actually is one month after today.

I would suggest you start using the Java 8 Date API.

       LocalDate lTodayLocalDate = LocalDate.now();
       Agenda.Appointment[] lTestAppointments = new Agenda.Appointment[]{
           new Agenda.AppointmentImplLocal()
               .withStartLocalDateTime(lTodayLocalDate.atTime(4, 00))
               .withEndLocalDateTime(lTodayLocalDate.atTime(5, 30))
               .withSummary("A")
               .withDescription("A much longer test description")
               .withAppointmentGroup(lAppointmentGroupMap.get("group07"))
       };
       ctrl.appointments().addAll(lTestAppointments);
tbeernot
  • 2,473
  • 4
  • 24
  • 31
  • Hi tbeernot, Thank you for your help. No, there are few differences between your code and mine. I don't have the class Agenda.AppointmentImplLocal but only the class Agenda.AppointmentImpl. – Merecol Jul 28 '15 at 13:17
  • I downloaded the jars using maven. Here the maven code of dependencies: org.jfxtras jfxtras-labs 8.0-r3 org.jfxtras jfxtras-agenda 8.0-r3 – Merecol Jul 28 '15 at 13:17
  • Moreover, when I use the following fxml ... And the following related java attribute inside the controller public Agenda agenda; – Merecol Jul 28 '15 at 13:18
  • I get the following error: lug 28, 2015 2:26:47 PM javafx.scene.control.Control loadSkinClass GRAVE: Failed to load skin 'jfxtras.internal.scene.control.skin.agenda.AgendaWeekSkin' for control Agenda[id=agenda, styleClass=Agenda AgendaWeekSkin] java.lang.NullPointerException Could you help me please? – Merecol Jul 28 '15 at 13:18
  • You really should use the R4-SNAPSHOT. The snapshots of JFXtras are more stable than the release, because we have labs for all the experimenst. So the snapshots have bug fixes that the latest release does not have. – tbeernot Jul 28 '15 at 16:48
  • Thank you for your help! Now it's working fine! I wasted 24 hours trying to understand why my classes were different :DD So I would like to ask you two more questions please: 1) Is it possible to change the rows and the columns? I don't want all the hours like rows and all the days like columns 2) Where could I find a detailed guide for managing Agenda events? I need to intercept its events Thank you again! Best Regards – Merecol Jul 28 '15 at 17:11
  • 3)Is it possible to customize the popup panel and the default content and graphic of the appointment placed on the agenda? – Merecol Jul 28 '15 at 17:25
  • 1) no, the skin is code like this 2) You need to listen to the properties of the appointment themselves, or on the appointments observable list. 3) the appointments are styled using CSS though the class it gets from the appointment group and there is an editAppointment callback where you can replace the popup with something you wrote yourself. – tbeernot Jul 29 '15 at 18:32