How can I add an action Listener onto an appointment in an agenda (JFXtras Agenda)

冷暖自知 提交于 2019-12-19 12:00:26

问题


How can I add an action Listener so that when an appointment on an agenda is clicked a new window with more details on that particular clicked appointment opens.


回答1:


It seems like Agenda has not api for that. You can see agenda's sources: AbstractAppointmentPane has mouse event logic.




回答2:


lAgenda.selectedAppointments().addListener(new ListChangeListener< Appointment >() {
     public void onChanged(Change<? extends Appointment> c) {
         while (c.next()) {
             if (c.wasPermutated()) {
                 for (int i = c.getFrom(); i < c.getTo(); ++i) {
                      //permutate
                 }
             } else if (c.wasUpdated()) {
                      //update item
             } else {
                 for (Appointment a : c.getRemoved()) {
                 }
                 for (Appointment a : c.getAddedSubList()) {
                     printAppointment(a);
                 }
             }
         }
     }
 });

Then print appointments:

private void printAppointment(Appointment a) {
    System.out.println(a.getSummary());
    System.out.println(a.getDescription());
}


来源:https://stackoverflow.com/questions/22681781/how-can-i-add-an-action-listener-onto-an-appointment-in-an-agenda-jfxtras-agend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!