Example usage for javafx.scene.control ComboBox editorProperty

List of usage examples for javafx.scene.control ComboBox editorProperty

Introduction

In this page you can find the example usage for javafx.scene.control ComboBox editorProperty.

Prototype

public final ReadOnlyObjectProperty<TextField> editorProperty() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>(list);

    emailComboBox.setValue("A");
    System.out.println(emailComboBox.editorProperty());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from w w w .j a  v a 2  s.  c  o  m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

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 w w .j  a v  a 2 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;

}