Код: Выделить всё
// fill the first TextField with String values from above textfields
textFieldPointCloudName.textProperty().bind(pointCloudNameBinding);
< /code>
и < /p>
// fill the second TextField from a DirectoryChooser or the clipboard and check its values
var isTargetPathValid = Bindings.createBooleanBinding(
() -> {
var path = pointCloudPath.getText();
if (path.isEmpty()) {
return false;
} else {
return FileUtils.isDirectory(path);
}
}, pointCloudPath.textProperty());
< /code>
Привязки и проверки двух текстовых полей выполняются, и они работают. Я могу активировать кнопку на этих двух привязках с < /p>
// checks the TextFields and enable the execute/run button if not empty
btnRun.disableProperty().bind(areTextFieldsEmpty);
< /code>
Я использовал этот код также в другой программе.@FXML
private ListView listView;
Код: Выделить всё
var selectedFiles = fileChooser.showOpenMultipleDialog(window);
var files = FXCollections.observableArrayList(selectedFiles);
listView.setItems(files);
// remove double-clicked items from the list
listView.setOnMouseClicked(mouseEvent -> {
if (mouseEvent.getClickCount() == 2) {
var selectedIndex = listView.getSelectionModel().getSelectedIndex();
listView.getItems().remove(selectedIndex);
}
});
Любой намек, как это сделать или что мне не хватает?>
Подробнее здесь: https://stackoverflow.com/questions/795 ... -in-javafx