List of usage examples for javafx.beans.property ReadOnlyObjectProperty addListener
void addListener(ChangeListener<? super T> listener);
From source file:de.ks.file.FileViewController.java
@Override public void initialize(URL location, ResourceBundle resources) { fileList.setItems(files);//from w w w .ja v a 2s . c o m MultipleSelectionModel<File> selectionModel = fileList.getSelectionModel(); selectionModel.setSelectionMode(SelectionMode.MULTIPLE); ReadOnlyObjectProperty<File> selection = selectionModel.selectedItemProperty(); selection.addListener((p, o, n) -> { folderName.setText(n == null ? "" : n.getParentFile().getAbsolutePath()); fileNameLabel.setText(n == null ? "" : n.getName()); }); BooleanBinding isDirectory = Bindings .createBooleanBinding(() -> selection.get() != null && selection.get().isDirectory(), selection); edit.disableProperty().bind(isDirectory); files.addListener((ListChangeListener<File>) change -> { files.forEach(file -> { if (!fileReferences.containsKey(file) && file.exists() && !file.isDirectory()) { fileReferences.put(file, fileStore.getReference(file)); } }); }); BooleanBinding disable = fileList.getSelectionModel().selectedItemProperty().isNull(); open.disableProperty().bind(disable); edit.disableProperty().bind(disable); openFolder.disableProperty().bind(disable); removeFile.disableProperty().bind(disable); }