finished
This commit is contained in:
parent
72d87a894e
commit
46c0e9d760
@ -24,12 +24,23 @@ public class AddressBookController {
|
|||||||
private final ObservableList<Contact> contacts = FXCollections.observableArrayList();
|
private final ObservableList<Contact> contacts = FXCollections.observableArrayList();
|
||||||
private final FilteredList<Contact> filteredContacts = new FilteredList<>(contacts);
|
private final FilteredList<Contact> filteredContacts = new FilteredList<>(contacts);
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
contactView.setItems(filteredContacts);
|
contactView.setItems(filteredContacts);
|
||||||
|
|
||||||
contacts.addListener((ListChangeListener<? super Contact>) (observable) -> updateContactCount());
|
contacts.addListener((ListChangeListener<? super Contact>) (observable) -> updateContactCount());
|
||||||
updateContactCount();
|
updateContactCount();
|
||||||
}
|
|
||||||
|
contactView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue != null) {
|
||||||
|
idField.setText(String.valueOf(newValue.getId()));
|
||||||
|
nameField.setText(newValue.getName());
|
||||||
|
phoneField.setText(newValue.getPhone());
|
||||||
|
emailField.setText(newValue.getEmail());
|
||||||
|
} else {
|
||||||
|
clearInputFields();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private Predicate<Contact> createFilterPredicate(String searchText) {
|
private Predicate<Contact> createFilterPredicate(String searchText) {
|
||||||
if (searchText == null || searchText.isBlank()) {
|
if (searchText == null || searchText.isBlank()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user