Example usage for javafx.beans.value ChangeListener ChangeListener

List of usage examples for javafx.beans.value ChangeListener ChangeListener

Introduction

In this page you can find the example usage for javafx.beans.value ChangeListener ChangeListener.

Prototype

ChangeListener

Source Link

Usage

From source file:caillou.company.clonemanager.gui.customComponent.locationContainer.LocationContainerController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    this.addLocationWithinGroupA();
    this.addLocationWithinGroupB();

    final LocationsModel locationsModel = mainModel.getLocationsModel();
    if (mainModel.getTaskModel().getCurrentTask().equals(TaskModel.TASK.DETECT_DOUBLONS)) {
        locationsModel.detectsIdentiqueFilesWithinALocationProperty()
                .bind(detectDoublonsWithinSameLocationId.selectedProperty());
        detectDoublonsWithinSameLocationId.selectedProperty().addListener(new ChangeListener<Boolean>() {

            @Override/*from ww w  .  jav a  2s .c o  m*/
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue,
                    Boolean newValue) {
                locationsModel.validLocations();
            }

        });
    }

}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Background Processes");
    Group root = new Group();
    Scene scene = new Scene(root, 330, 120, Color.WHITE);

    BorderPane mainPane = new BorderPane();
    root.getChildren().add(mainPane);/*w  ww. j a  v a  2s  .  c om*/

    final Label label = new Label("Files Transfer:");
    final ProgressIndicator progressIndicator = new ProgressIndicator(0);

    final HBox hb = new HBox();
    hb.setSpacing(5);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(label, progressIndicator);
    mainPane.setTop(hb);

    final Button startButton = new Button("Start");
    final Button cancelButton = new Button("Cancel");
    final HBox hb2 = new HBox();
    hb2.setSpacing(5);
    hb2.setAlignment(Pos.CENTER);
    hb2.getChildren().addAll(startButton, cancelButton);
    mainPane.setBottom(hb2);

    startButton.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent event) {
            startButton.setDisable(true);
            progressIndicator.setProgress(0);
            cancelButton.setDisable(false);
            copyWorker = createWorker();

            progressIndicator.progressProperty().unbind();
            progressIndicator.progressProperty().bind(copyWorker.progressProperty());

            copyWorker.messageProperty().addListener(new ChangeListener<String>() {
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    System.out.println(newValue);
                }
            });

            new Thread(copyWorker).start();
        }
    });
    cancelButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            startButton.setDisable(false);
            cancelButton.setDisable(true);
            copyWorker.cancel(true);
            progressIndicator.progressProperty().unbind();
            progressIndicator.setProgress(0);
            System.out.println("cancelled.");
        }
    });
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:ch.unibas.fittingwizard.presentation.addmolecule.CoordinatesPage.java

private void setupCoordinatesTable() {
    coordinatesTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<XyzAtom>() {
        @Override/*from   w ww .j a v  a2  s  .  c  o  m*/
        public void changed(ObservableValue<? extends XyzAtom> observableValue, XyzAtom atomOld,
                XyzAtom atomNew) {
            if (atomNew != null) {
                logger.info("Atom selected " + atomNew.getName());
                visualization.selectAtom(atomNew);
            }
        }
    });
    nameColumn.setCellValueFactory(new PropertyValueFactory<XyzAtom, String>("name"));
    xColumn.setCellValueFactory(new PropertyValueFactory<XyzAtom, String>("x"));
    yColumn.setCellValueFactory(new PropertyValueFactory<XyzAtom, String>("y"));
    zColumn.setCellValueFactory(new PropertyValueFactory<XyzAtom, String>("z"));
}

From source file:org.yardstick.spark.util.FXCSSUpdater.java

public void bindCss(final StringProperty cssProperty) {
    cssProperty.addListener(new ChangeListener<String>() {
        @Override//from w w w.j  a  v a2s .  c om
        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");
                }
            });
        }
    });
}

From source file:org.ado.biblio.desktop.update.FileDownloadTask.java

public FileDownloadTask(HttpClient httpClient, String remoteUrl, File localFile, int bufferSize) {
    this.httpClient = httpClient;
    this.remoteUrl = remoteUrl;
    this.localFile = localFile;
    this.bufferSize = bufferSize;

    stateProperty().addListener(new ChangeListener<State>() {
        public void changed(ObservableValue<? extends State> source, State oldState, State newState) {
            if (newState.equals(State.SUCCEEDED)) {
                onSuccess();//from  ww  w . j av  a  2  s .co m
            } else if (newState.equals(State.FAILED)) {
                onFailed();
            }
        }
    });
}

From source file:com.rcs.shoe.shop.fx.controller.ui.Controller.java

protected ChangeListener getDigitChangeListener(final TextField textField) {
    ChangeListener<String> result = new ChangeListener<String>() {
        @Override//from  w  w  w .j a  v  a  2  s  . c  om
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (StringUtils.isBlank(newValue)) {
                textField.textProperty().setValue("");
            } else if (NumberUtils.isDigits(newValue)) {
                textField.textProperty().setValue(newValue);
            } else {
                textField.textProperty().setValue(oldValue);
            }
        }
    };
    return result;
}

From source file:org.nmrfx.processor.gui.RefManager.java

RefManager(ProcessorController processorController, PropertySheet refSheet) {
    this.processorController = processorController;
    this.refSheet = refSheet;
    doubleListener = new ChangeListener<Number>() {
        @Override/*from   w  w w.  j  ava2  s.  co  m*/
        public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    intListener = new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    boolListener = new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean bool, Boolean bool2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    stringListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String string, String string2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    complexListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    listListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };

    refSheet.setPropertyEditorFactory(new NvFxPropertyEditorFactory(processorController));
    refSheet.setMode(PropertySheet.Mode.NAME);
    refSheet.setModeSwitcherVisible(false);
    refSheet.setSearchBoxVisible(false);

}

From source file:caillou.company.clonemanager.gui.customComponent.settings.SettingsController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    languageComboBoxId.setCellFactory(new Callback<ListView<Language>, ListCell<Language>>() {
        @Override/*from  w  ww .ja v a2  s.co m*/
        public ListCell<Language> call(ListView<Language> language) {
            return new LanguageListCell();
        }
    });

    languageComboBoxId.setButtonCell(new LanguageListCell());

    Language frenchLanguage = new Language(Locale.FRENCH);
    Language englishLanguage = new Language(Locale.ENGLISH);
    ObservableList<Language> languages = FXCollections.observableArrayList();
    languages.add(englishLanguage);
    languages.add(frenchLanguage);
    languageComboBoxId.setItems(languages);

    Locale currentLocale = SpringFxmlLoader.getLocale();
    if (currentLocale.equals(Locale.FRENCH)) {
        languageComboBoxId.setValue(frenchLanguage);
    } else {
        languageComboBoxId.setValue(englishLanguage);
    }

    languageComboBoxId.valueProperty().addListener(new ChangeListener<Language>() {

        @Override
        public void changed(ObservableValue<? extends Language> observable, Language oldValue,
                Language newValue) {
            SpringFxmlLoader.changeLocale(newValue.getLocale());
        }
    });
}

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

public static void bindStyleClass(@Nonnull final Node nodeToStyle, @Nonnull final String styleClass,
        ObservableBooleanValue value) {/*from w  w  w. j  a v  a 2 s .  c  o  m*/
    updateStyleClasses(nodeToStyle, styleClass, value.getValue());
    value.addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue) {
            updateStyleClasses(nodeToStyle, styleClass, newValue);
        }

    });
}

From source file:com.panemu.tiwulfx.control.skin.LookupFieldSkin.java

public LookupFieldSkin(LookupField<T> control) {
    super(control, new LookupFieldBehavior<>(control));
    this.lookupField = control;
    // move focus in to the textfield
    lookupField.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override//from w w w  .j  av  a2s .  co m
        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) {
            if (hasFocus) {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        textField.requestFocus();
                    }
                });
            }

        }
    });
    initialize();

    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean hasFocus) {
            if (!hasFocus) {
                validate();
            }
        }
    });

    lookupField.addEventFilter(InputEvent.ANY, new EventHandler<InputEvent>() {
        @Override
        public void handle(InputEvent t) {
            if (textField == null) {
                return;
            }

            // When the user hits the enter or F4 keys, we respond before 
            // ever giving the event to the TextField.
            if (t instanceof KeyEvent) {
                KeyEvent ke = (KeyEvent) t;

                if ((ke.getCode() == KeyCode.F10 || ke.getCode() == KeyCode.ESCAPE
                        || ke.getCode() == KeyCode.ENTER) && !ke.isControlDown()) {

                    // RT-23275: The TextField fires F10 and ESCAPE key events
                    // up to the parent, which are then fired back at the 
                    // TextField, and this ends up in an infinite loop until
                    // the stack overflows. So, here we consume these two
                    // events and stop them from going any further.
                    t.consume();
                    return;
                }
            }
        }
    });

    textField.promptTextProperty().bind(lookupField.promptTextProperty());
    getSkinnable().requestLayout();

    registerChangeListener(control.showingSuggestionProperty(), PROP_SHOWING_SUGGESTION);
    registerChangeListener(control.showingLookupDialogProperty(), PROP_SHOWING_LOOKUP_WINDOW);
    registerChangeListener(control.resettingDisplayTextProperty(), PROP_RESETTING_DISPLAY_TEXT);
}