Привет, я пишу это приложение Javafx для школы, и я пытаюсь реализовать страницу, на которой список ListView отображает список временных интервалов (пользовательский класс с двумя датами и тремя полями UUID - 1 PK и 2 FK для базы данных).
Для этой цели я написал пользовательский сотовой связи, как вопрос, Custom INEFIEST in ListView javafx . Теперь моя проблема в том, что, хотя я добавляю новый объект временного интервала в элементы ListView, что ничто не отображается. По -видимому, параметр элемента в методе UpdateItem моего сотовой связи является нулевым. Что я делаю не так? timeSlotListView.setCellFactory(new Callback() {
@Override
public ListCell call(ListView param) {
return new ListCell() {
private TextField textField = new TextField("Text");
private Button button = new Button("Button");
private BorderPane bp = new BorderPane(null, null, textField, null, button);
@Override
protected void updateItem(TimeSlot item, boolean empty) {
System.out.println("VBox Bounds: " + findTripDateVBox.getBoundsInParent());
System.out.println("ListView Bounds: " + timeSlotListView.getBoundsInParent());
System.out.println("item is null " + (item == null));
System.out.println("isEmpty " + empty);
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
setGraphic(bp);
} else {
setText(item.getId().toString());
setGraphic(bp);
}
}
};
}
});
< /code>
Как я добавляю новый элемент в ListView: < /p>
Date fromDate = java.sql.Date.valueOf(fromDatePicker.getValue());
Date toDate = java.sql.Date.valueOf(toDatePicker.getValue());
// Sample object to test the listview. the last two parameteres would be the uuids of other objects.
// The own Id gets generated in the constructor
TimeSlot timeSlot = new TimeSlot(fromDate, toDate, UUID.randomUUID(), UUID.randomUUID());
System.out.println(timeSlot.getId().toString());
timeSlotListView.getItems().add(timeSlot);
System.out.println(timeSlotListView.getItems().size());
< /code>
fxml-файл Adherpt: < /p>
Подробнее здесь: https://stackoverflow.com/questions/796 ... y-anything