如何在单击AppointmentPane时获取约会详细信息 - JFXtras [英] How to get appointment details when an AppointmentPane is clicked - JFXtras
问题描述
当用户点击从中检索到的特定约会时,我想打印预约的摘要
和说明
数据库。
I would like to print out an appointment's summary
and description
when a user clicks on a particular appointment retrieved from the database.
我正试图通过以下方式实现:
I'm trying to implement this with something like:
lAgenda.selectedAppointments().addListener(new ListChangeListener<Appointment>() {
@Override
public void onChanged(Change<? extends Appointment> c) {
System.out.println(c.toString());
}
});
但是,我只能得到这个:
I however, only get this:
com.sun.javafx.collections.NonIterableChange$GenericAddRemoveChange@1ef0f08
com.sun.javafx.collections.NonIterableChange$SimpleAddChange@1c3e48b
com.sun.javafx.collections.NonIterableChange$GenericAddRemoveChange@d57e70
com.sun.javafx.collections.NonIterableChange$SimpleAddChange@6022e2
com.sun.javafx.collections.NonIterableChange$GenericAddRemoveChange@54ddc1
如何检索其他项目,例如从中检索约会的数据库行中的行ID?谢谢大家。
How can I retrieve other items, like the ID of the row in the database row the appointment is being retrieved from? Thank you all.
推荐答案
您正在使用正确的属性来获知选择更改的通知。
You are using the right property to be notified of the selection change.
您收到了 ListChangeListener。更改。如javadoc中所述,应该以这种方式使用更改:
You received a ListChangeListener.Change. As described in the javadoc, a change should be used in the this way :
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);
}
}
}
}
});
现在,您可以打印约会摘要和说明:
Now, you could print out appointment summary and description :
private void printAppointment(Appointment a) {
System.out(a.getSummary());
System.out(a.getDescription());
}
如果您需要约会对象的某些特定属性(如数据库ID) ,您可以通过扩展来创建预约课程AppointmentImpl 或实施预约
If you need some specific properties on the appointment object (like a database id), you could create your appointment class by extending AppointmentImpl or by implementing Appointment
这篇关于如何在单击AppointmentPane时获取约会详细信息 - JFXtras的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!