Example usage for javafx.scene.control TableView setPrefHeight

List of usage examples for javafx.scene.control TableView setPrefHeight

Introduction

In this page you can find the example usage for javafx.scene.control TableView setPrefHeight.

Prototype

public final void setPrefHeight(double value) 

Source Link

Usage

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);// w w  w.  j  a  va 2s  . 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;

}