И мне интересно, почему связывание с редактором все еще работает при замене Maincontroller.java личность. работает) < /p>
Код: Выделить всё
personList.setCellFactory(param -> new ListCell
(){});
Код: Выделить всё
personList.setCellFactory(param -> new ListCell
());
не работает :
Код: Выделить всё
personList.setCellFactory(new PersonListCellFactory());
Код: Выделить всё
personList.setCellFactory(new PersonListCellFactory(){});
Код: Выделить всё
package nestedcontrollerexample;
import javafx.beans.binding.Bindings;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.util.Callback;
public class PersonListCellFactory implements Callback {
@Override
public ListCell call(ListView param) {
return new ListCell() {
@Override
public void updateItem(Person person, boolean empty) {
super.updateItem(person, empty);
textProperty().unbind();
if (person != null) {
textProperty().bind(Bindings.format("%s %s", person.firstNameProperty(), person.lastNameProperty()));
}
}
};
}
}
Подробнее здесь: https://stackoverflow.com/questions/348 ... nner-class