Example usage for javafx.scene.control ButtonType APPLY

List of usage examples for javafx.scene.control ButtonType APPLY

Introduction

In this page you can find the example usage for javafx.scene.control ButtonType APPLY.

Prototype

ButtonType APPLY

To view the source code for javafx.scene.control ButtonType APPLY.

Click Source Link

Document

A pre-defined ButtonType that displays "Apply" and has a ButtonData of ButtonData#APPLY .

Usage

From source file:dev.archiecortez.jfacelog.dialogs.NewPassDialog.java

public NewPassDialog() throws IOException {
    super();/*  w w  w . j  av a2  s . c  om*/
    FXMLLoader loader = new FXMLLoader(getClass().getResource("newpassdialog.fxml"));
    loader.setController(this);

    Parent root = loader.load();
    this.getDialogPane().setContent(root);
    getDialogPane().getButtonTypes().add(ButtonType.APPLY);
    getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
    getDialogPane().lookupButton(ButtonType.APPLY).disableProperty()
            .bind(newPassword.textProperty().isNotEqualTo(newPasswordCopy.textProperty())
                    .or(newPassword.textProperty().isEmpty()).or(oldPassword.textProperty().isEmpty()));

    setResultConverter(value -> {
        if (value == ButtonType.APPLY) {
            return new Pair<>(oldPassword.getText(), newPassword.getText());
        } else {
            return null;
        }
    });
}