當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。