List of usage examples for javafx.beans.property StringProperty addListener
void addListener(ChangeListener<? super T> listener);
From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java
@Override protected BatchUpdateDialog createDialog() { ObservableList<UpdateFileNamesFromTagsItem> items = FXCollections.observableArrayList( this.getOtherFiles().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList())); StringProperty patternFieldProperty = new SimpleStringProperty(); List<String> patternItems = Arrays.asList("${track} ${title}"); ComboBox<String> patternBox = new ComboBox<>(FXCollections.observableArrayList(patternItems)); patternBox.setEditable(true);//from w ww. jav a2 s .c o m patternBox.setMaxWidth(Double.MAX_VALUE); Bindings.bindBidirectional(patternFieldProperty, patternBox.editorProperty().get().textProperty()); HBox.setHgrow(patternBox, Priority.ALWAYS); Button executeButton = new Button(this.getLocalization().executeRename(), new ImageView(new Image(UpdateFileNamesFromTagsActionEventHandler.class.getClassLoader() .getResourceAsStream("icons/16/save.png")))); executeButton.setDisable(true); patternFieldProperty .addListener((o, oldValue, newValue) -> executeButton.setDisable(newValue.length() <= 0)); HBox patternFieldPane = new HBox(10, patternBox, executeButton); patternFieldPane.setPadding(new Insets(5, 5, 5, 5)); TitledPane patternFieldTitlePane = new TitledPane(this.getLocalization().fileNamePattern(), patternFieldPane); patternFieldTitlePane.setCollapsible(false); TableView<?> newFileNamesPane = this.createNewFileNamesPane(items); newFileNamesPane.setPrefHeight(400); VBox.setVgrow(newFileNamesPane, Priority.ALWAYS); VBox actionPane = new VBox(10, patternFieldTitlePane, newFileNamesPane); // Create the dialog and finish BatchUpdateDialog dialog = new BatchUpdateDialog(); dialog.setDialogPrefWidth(800); dialog.setDialogTitle(this.getLocalization().updateFileNames()); dialog.setActionPane(actionPane); dialog.setLegendPane(this.createLegendPane()); // Add listeners this.getOtherFiles().addListener( new WeakListChangeListener<>((Change<? extends TaggableFile> change) -> items.setAll(change .getList().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList())))); patternFieldProperty.addListener((o, oldValue, newValue) -> this.computeNewFileNames(items, newValue)); executeButton.setOnAction(event -> { this.updateNewFileNames(items); ((Stage) executeButton.getScene().getWindow()).close(); }); return dialog; }
From source file:org.yardstick.spark.util.FXCSSUpdater.java
public void bindCss(final StringProperty cssProperty) { cssProperty.addListener(new ChangeListener<String>() { @Override//from ww w . j a v a2 s . c o m public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { cssHolder.str = cssProperty.get(); Platform.runLater(new Runnable() { public void run() { scene.getStylesheets().clear(); scene.getStylesheets().add("internal:stylesheet.css"); } }); } }); }