当前位置: 首页>>代码示例>>Java>>正文


Java BooleanBinding.addListener方法代码示例

本文整理汇总了Java中javafx.beans.binding.BooleanBinding.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanBinding.addListener方法的具体用法?Java BooleanBinding.addListener怎么用?Java BooleanBinding.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.beans.binding.BooleanBinding的用法示例。


在下文中一共展示了BooleanBinding.addListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle r) {
    BooleanBinding textNotEmpty = field.textProperty().isEqualTo("").not();

    BooleanBinding labelActive = textNotEmpty.or(field.focusedProperty());

    BooleanBinding fieldActive = textNotEmpty.and(field.focusedProperty());

    labelActive.addListener(new LabelFadeIn());

    fieldActive.addListener(new FieldActiveStyler());

    label.setVisible(false);
    label.visibleProperty().bind(labelActive);
    label.textProperty().bind(field.promptTextProperty());
    label.setLabelFor(field);

    // make sure that any click within this control will give focus to the input field
    field.getParent().setOnMouseClicked((e) -> { field.requestFocus(); });
}
 
开发者ID:andytill,项目名称:floaty-field,代码行数:21,代码来源:FloatyFieldView.java

示例2: bindForValidity

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
private BooleanBinding bindForValidity(boolean withConfirmation, TextField electionOfficer1Password, TextField electionOfficer2Password, Label errorMessage, Node confirmButton) {
    BooleanBinding passwordsValid = Bindings.createBooleanBinding(
            () -> withConfirmation ? arePasswordsEqualAndValid(electionOfficer1Password.textProperty(), electionOfficer2Password.textProperty()) : isPasswordValid(electionOfficer1Password.getText()),
            electionOfficer1Password.textProperty(),
            electionOfficer2Password.textProperty());
    passwordsValid.addListener((observable, werePasswordsValid, arePasswordsValid) -> {
        confirmButton.setDisable(!arePasswordsValid);
        errorMessage.setVisible(!arePasswordsValid && withConfirmation);
    });
    return passwordsValid;
}
 
开发者ID:republique-et-canton-de-geneve,项目名称:chvote-1-0,代码行数:12,代码来源:PasswordDialogController.java

示例3: initializeBindings

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
private void initializeBindings() {
    encryptButton.setDisable(true);
    BooleanBinding plainTextsEmpty = Bindings.createBooleanBinding(plainTexts::isEmpty, plainTexts);
    plainTextsEmpty.addListener(
            (observable, oldValue, isPlainTextListEmpty) ->
                    encryptButton.setDisable(isPlainTextListEmpty)
    );

    decryptButton.setDisable(true);
    cipherTexts.addListener((ListChangeListener<AuthenticatedBallot>) c -> decryptButton.setDisable(c.getList().isEmpty()));
}
 
开发者ID:republique-et-canton-de-geneve,项目名称:chvote-1-0,代码行数:12,代码来源:KeyTestingController.java

示例4: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
public void initialize(@Nullable KeyParameter aesKey) {
    DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed();
    if (aesKey == null) {
        if (seed.isEncrypted()) {
            log.info("Wallet is encrypted, requesting password first.");
            // Delay execution of this until after we've finished initialising this screen.
            Platform.runLater(() -> askForPasswordAndRetry());
            return;
        }
    } else {
        this.aesKey = aesKey;
        seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey);
        // Now we can display the wallet seed as appropriate.
        passwordButton.setText("Remove password");
    }

    // Set the date picker to show the birthday of this wallet.
    Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
    LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
    datePicker.setValue(origDate);

    // Set the mnemonic seed words.
    final List<String> mnemonicCode = seed.getMnemonicCode();
    checkNotNull(mnemonicCode);    // Already checked for encryption.
    String origWords = Utils.join(mnemonicCode);
    wordsArea.setText(origWords);

    // Validate words as they are being typed.
    MnemonicCode codec = unchecked(MnemonicCode::new);
    TextFieldValidator validator = new TextFieldValidator(wordsArea, text ->
        !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text)))
    );

    // Clear the date picker if the user starts editing the words, if it contained the current wallets date.
    // This forces them to set the birthday field when restoring.
    wordsArea.textProperty().addListener(o -> {
        if (origDate.equals(datePicker.getValue()))
            datePicker.setValue(null);
    });

    BooleanBinding datePickerIsInvalid = or(
            datePicker.valueProperty().isNull(),

            createBooleanBinding(() ->
                    datePicker.getValue().isAfter(LocalDate.now())
            , /* depends on */ datePicker.valueProperty())
    );

    // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
    // or if the date field isn't set, or if it's in the future.
    restoreButton.disableProperty().bind(
            or(
                    or(
                            not(validator.valid),
                            equal(origWords, wordsArea.textProperty())
                    ),

                    datePickerIsInvalid
            )
    );

    // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
    datePickerIsInvalid.addListener((dp, old, cur) -> {
        if (cur) {
            datePicker.getStyleClass().add("validation_error");
        } else {
            datePicker.getStyleClass().remove("validation_error");
        }
    });
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:71,代码来源:WalletSettingsController.java

示例5: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
public void initialize(@Nullable KeyParameter aesKey) {
    DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed();
    if (aesKey == null) {
        if (seed.isEncrypted()) {
            log.info("Wallet is encrypted, requesting password first.");
            // Delay execution of this until after we've finished initialising this screen.
            Platform.runLater(() -> askForPasswordAndRetry());
            return;
        }
    } else {
        this.aesKey = aesKey;
        seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey);
        // Now we can display the wallet seed as appropriate.
        passwordButton.setText("Remove password");
    }

    // Set the date picker to show the birthday of this wallet.
    Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
    LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
    datePicker.setValue(origDate);

    // Set the mnemonic seed words.
    final List<String> mnemonicCode = seed.getMnemonicCode();
    checkNotNull(mnemonicCode);    // Already checked for encryption.
    String origWords = Joiner.on(" ").join(mnemonicCode);
    wordsArea.setText(origWords);

    // Validate words as they are being typed.
    MnemonicCode codec = unchecked(MnemonicCode::new);
    TextFieldValidator validator = new TextFieldValidator(wordsArea, text ->
        !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text)))
    );

    // Clear the date picker if the user starts editing the words, if it contained the current wallets date.
    // This forces them to set the birthday field when restoring.
    wordsArea.textProperty().addListener(o -> {
        if (origDate.equals(datePicker.getValue()))
            datePicker.setValue(null);
    });

    BooleanBinding datePickerIsInvalid = or(
            datePicker.valueProperty().isNull(),

            createBooleanBinding(() ->
                    datePicker.getValue().isAfter(LocalDate.now())
            , /* depends on */ datePicker.valueProperty())
    );

    // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
    // or if the date field isn't set, or if it's in the future.
    restoreButton.disableProperty().bind(
            or(
                    or(
                            not(validator.valid),
                            equal(origWords, wordsArea.textProperty())
                    ),

                    datePickerIsInvalid
            )
    );

    // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
    datePickerIsInvalid.addListener((dp, old, cur) -> {
        if (cur) {
            datePicker.getStyleClass().add("validation_error");
        } else {
            datePicker.getStyleClass().remove("validation_error");
        }
    });
}
 
开发者ID:Techsoul192,项目名称:legendary-guide,代码行数:71,代码来源:WalletSettingsController.java

示例6: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
public void initialize (@Nullable KeyParameter aesKey) {
    DeterministicSeed seed = Main.wallet.getKeyChainSeed();
    if (aesKey == null) {
        if (seed.isEncrypted()) {
            log.info("Wallet is encrypted, requesting password first.");
            // Delay execution of this until after we've finished initialising this screen.
            Platform.runLater(() -> askForPasswordAndRetry());
            return;
        }
    } else {
        this.aesKey = aesKey;
        seed = seed.decrypt(checkNotNull(Main.wallet.getKeyCrypter()), "", aesKey);
        // Now we can display the wallet seed as appropriate.
        passwordButton.setText("Remove password");
    }

    // Set the date picker to show the birthday of this wallet.
    Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
    LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
    datePicker.setValue(origDate);

    // Set the mnemonic seed words.
    final List<String> mnemonicCode = seed.getMnemonicCode();
    checkNotNull(mnemonicCode);    // Already checked for encryption.
    String origWords = Utils.join(mnemonicCode);
    wordsArea.setText(origWords);

    // Validate words as they are being typed.
    MnemonicCode codec = unchecked(MnemonicCode::new);
    TextFieldValidator validator = new TextFieldValidator(wordsArea, text ->
            !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text)))
    );

    // Clear the date picker if the user starts editing the words, if it contained the current wallets date.
    // This forces them to set the birthday field when restoring.
    wordsArea.textProperty().addListener(o -> {
        if (origDate.equals(datePicker.getValue())) {
            datePicker.setValue(null);
        }
    });

    BooleanBinding datePickerIsInvalid = or(
            datePicker.valueProperty().isNull(),

            createBooleanBinding(() ->
                            datePicker.getValue().isAfter(LocalDate.now())
                    , /* depends on */ datePicker.valueProperty())
    );

    // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
    // or if the date field isn't set, or if it's in the future.
    restoreButton.disableProperty().bind(
            or(
                    or(
                            not(validator.valid),
                            equal(origWords, wordsArea.textProperty())
                    ),

                    datePickerIsInvalid
            )
    );

    // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
    datePickerIsInvalid.addListener((dp, old, cur) -> {
        if (cur) {
            datePicker.getStyleClass().add("validation_error");
        } else {
            datePicker.getStyleClass().remove("validation_error");
        }
    });
}
 
开发者ID:blockchain,项目名称:thunder,代码行数:72,代码来源:WalletSettingsController.java

示例7: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
public void initialize(@Nullable KeyParameter aesKey) {
    DeterministicSeed seed = Main.nubits.wallet().getKeyChainSeed();
    if (aesKey == null) {
        if (seed.isEncrypted()) {
            log.info("Wallet is encrypted, requesting password first.");
            // Delay execution of this until after we've finished initialising this screen.
            Platform.runLater(() -> askForPasswordAndRetry());
            return;
        }
    } else {
        this.aesKey = aesKey;
        seed = seed.decrypt(checkNotNull(Main.nubits.wallet().getKeyCrypter()), "", aesKey);
        // Now we can display the wallet seed as appropriate.
        passwordButton.setText("Remove password");
    }

    // Set the date picker to show the birthday of this wallet.
    Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
    LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
    datePicker.setValue(origDate);

    // Set the mnemonic seed words.
    final List<String> mnemonicCode = seed.getMnemonicCode();
    checkNotNull(mnemonicCode);    // Already checked for encryption.
    String origWords = Utils.join(mnemonicCode);
    wordsArea.setText(origWords);

    // Validate words as they are being typed.
    MnemonicCode codec = unchecked(MnemonicCode::new);
    TextFieldValidator validator = new TextFieldValidator(wordsArea, text ->
        !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text)))
    );

    // Clear the date picker if the user starts editing the words, if it contained the current wallets date.
    // This forces them to set the birthday field when restoring.
    wordsArea.textProperty().addListener(o -> {
        if (origDate.equals(datePicker.getValue()))
            datePicker.setValue(null);
    });

    BooleanBinding datePickerIsInvalid = or(
            datePicker.valueProperty().isNull(),

            createBooleanBinding(() ->
                    datePicker.getValue().isAfter(LocalDate.now())
            , /* depends on */ datePicker.valueProperty())
    );

    // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
    // or if the date field isn't set, or if it's in the future.
    restoreButton.disableProperty().bind(
            or(
                    or(
                            not(validator.valid),
                            equal(origWords, wordsArea.textProperty())
                    ),

                    datePickerIsInvalid
            )
    );

    // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
    datePickerIsInvalid.addListener((dp, old, cur) -> {
        if (cur) {
            datePicker.getStyleClass().add("validation_error");
        } else {
            datePicker.getStyleClass().remove("validation_error");
        }
    });
}
 
开发者ID:Cybnate,项目名称:NuBitsj,代码行数:71,代码来源:WalletSettingsController.java

示例8: initialize

import javafx.beans.binding.BooleanBinding; //导入方法依赖的package包/类
public void initialize(@Nullable KeyParameter aesKey) {
    DeterministicSeed seed = Main.bitcoin.wallet().getKeyChainSeed();
    if (aesKey == null) {
        if (seed.isEncrypted()) {
            log.info("Wallet is encrypted, requesting password first.");
            // Delay execution of this until after we've finished initialising this screen.
            Platform.runLater(() -> askForPasswordAndRetry());
            return;
        }
    } else {
        this.aesKey = aesKey;
        seed = seed.decrypt(checkNotNull(Main.bitcoin.wallet().getKeyCrypter()), "", aesKey);
        // Now we can display the wallet seed as appropriate.
        passwordButton.setText("Remove password");
    }

    // Set the date picker to show the birthday of this wallet.
    Instant creationTime = Instant.ofEpochSecond(seed.getCreationTimeSeconds());
    LocalDate origDate = creationTime.atZone(ZoneId.systemDefault()).toLocalDate();
    datePicker.setValue(origDate);

    // Set the mnemonic seed words.
    final List<String> mnemonicCode = seed.getMnemonicCode();
    checkNotNull(mnemonicCode);    // Already checked for encryption.
    String origWords = Utils.SPACE_JOINER.join(mnemonicCode);
    wordsArea.setText(origWords);

    // Validate words as they are being typed.
    MnemonicCode codec = unchecked(MnemonicCode::new);
    TextFieldValidator validator = new TextFieldValidator(wordsArea, text ->
        !didThrow(() -> codec.check(Splitter.on(' ').splitToList(text)))
    );

    // Clear the date picker if the user starts editing the words, if it contained the current wallets date.
    // This forces them to set the birthday field when restoring.
    wordsArea.textProperty().addListener(o -> {
        if (origDate.equals(datePicker.getValue()))
            datePicker.setValue(null);
    });

    BooleanBinding datePickerIsInvalid = or(
            datePicker.valueProperty().isNull(),

            createBooleanBinding(() ->
                    datePicker.getValue().isAfter(LocalDate.now())
            , /* depends on */ datePicker.valueProperty())
    );

    // Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
    // or if the date field isn't set, or if it's in the future.
    restoreButton.disableProperty().bind(
            or(
                    or(
                            not(validator.valid),
                            equal(origWords, wordsArea.textProperty())
                    ),

                    datePickerIsInvalid
            )
    );

    // Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
    datePickerIsInvalid.addListener((dp, old, cur) -> {
        if (cur) {
            datePicker.getStyleClass().add("validation_error");
        } else {
            datePicker.getStyleClass().remove("validation_error");
        }
    });
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:71,代码来源:WalletSettingsController.java


注:本文中的javafx.beans.binding.BooleanBinding.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。