/** * init fxml when loaded. */ @PostConstruct public void init() { jfxComboBox.focusedProperty().addListener((o, oldVal, newVal) -> { if (!newVal) { jfxComboBox.validate(); } }); ChangeListener<? super Boolean> comboBoxFocus = (o, oldVal, newVal) -> { if (!newVal) { jfxEditableComboBox.validate(); } }; jfxEditableComboBox.focusedProperty().addListener(comboBoxFocus); jfxEditableComboBox.getEditor().focusedProperty().addListener(comboBoxFocus); jfxEditableComboBox.setConverter(new StringConverter<Label>() { @Override public String toString(Label object) { return object==null? "" : object.getText(); } @Override public Label fromString(String string) { return string == null || string.isEmpty() ? null : new Label(string); } }); }
attachListener(editor.focusedProperty(), (ov, wasFocused, isFocused) -> { if (wasFocused) { try {
BookmarksLevelComboBox() { validationSupport.setValidator(Validators.alwaysFalse()); setEditable(true); getSelectionModel().selectFirst(); valueProperty().addListener((o, oldVal, newVal) -> validate()); validationSupport.validationStateProperty().addListener(o -> { if (validationSupport.validationStateProperty().get() == ValidationState.INVALID) { getEditor().getStyleClass().addAll(Style.INVALID.css()); } else { getEditor().getStyleClass().removeAll(Style.INVALID.css()); } }); getEditor().focusedProperty().addListener((obs, old, isFocused) -> { // workaround for https://bugs.openjdk.java.net/browse/JDK-8136838 if (!isFocused) { String newVal = getEditor().getText(); if (nonNull(newVal) && !newVal.equals(getValue())) { setValue(newVal); } } }); }
/** * Unbinds everything */ public void unbind() { property.removeListener(text2fieldListener); textField.focusedProperty().removeListener(focusLostListener); textField.onKeyPressedProperty().setValue(null); }
/** * A handler that is executed on enter or focus lost */ public void addCommitHandler(@Nonnull CommitHandler commitHandler) { textField.focusedProperty().addListener((observable, oldValue, newValue) -> commitHandler.commit(AdvancedTextField.this, textField.getText())); textField.setOnAction(event -> commitHandler.commit(AdvancedTextField.this, textField.getText())); }
/** {@inheritDoc} */ @Override public void dispose(){ getCompletionTarget().textProperty().removeListener(textChangeListener); getCompletionTarget().focusedProperty().removeListener(focusChangedListener); }
commitEdit(this.converter.fromString(textField.getText())); }); textField.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (!isNowFocused) { commitEdit(this.converter.fromString(textField.getText()));
/** * Creates a new auto-completion binding between the given textField * and the given suggestion provider. * * @param textField * @param suggestionProvider */ public AutoCompletionTextFieldBinding(final TextField textField, Callback<ISuggestionRequest, Collection<T>> suggestionProvider, final StringConverter<T> converter) { super(textField, suggestionProvider, converter); this.converter = converter; getCompletionTarget().textProperty().addListener(textChangeListener); getCompletionTarget().focusedProperty().addListener(focusChangedListener); }
private void createTextField() { textField = new TextField(getString()); textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2); textField.focusedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) { if (!arg2) { commitEdit(textField.getText()); } } }); }
textField.focusedProperty().addListener(focusLostListener);
private void createTextField() { textField = new TextField(getString()); textField.setMinWidth(this.getWidth() - this.getGraphicTextGap()* 2); textField.focusedProperty().addListener( (ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) -> { if (!arg2) { commitEdit(textField.getText()); } }); }
getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> { if (!newValue) simulateEnterPressed();
textField.focusedProperty().addListener((observable, oldValue, newValue) -> updateLastChange("focus changed")); textField.selectedTextProperty().addListener((observable, oldValue, newValue) -> updateLastChange("selected text changed")); textField.focusedProperty().addListener((observable, oldValue, newValue) -> { if (!newValue) { textField.setText(converter.toString(property.getValue()));
/** * {@inheritDoc} */ @Override public void setupValueChangedListeners() { super.setupValueChangedListeners(); field.multilineProperty().addListener((observable, oldValue, newValue) -> { stack.setPrefHeight(newValue ? 80 : 0); readOnlyLabel.setPrefHeight(newValue ? 80 : 26); }); field.errorMessagesProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(field.isMultiline() ? editableArea : editableField)); editableField.focusedProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(editableField)); editableArea.focusedProperty().addListener((observable, oldValue, newValue) -> toggleTooltip(editableArea)); }
public AquaTextFieldSkin(final TextField textfield) { super(textfield); registerChangeListener(textfield.focusedProperty(), "FOCUSED"); if (getSkinnable().isFocused()) { setFocusBorder();
target.getStyleClass().remove("selectedTableViewControl"); if (newValue) { if (!filterField.focusedProperty().get()) { target.getStyleClass().add("selectedTableViewControl"); if (!filterField.focusedProperty().get() && !tableView.focusedProperty().get() && Strings.isNullOrEmpty(filterField.getText())) { FadeTransition ft = new FadeTransition(Duration.millis(fadeTransitionDuration), target); ft.setFromValue(1.0); filterField.focusedProperty().addListener(focusChangeListener);
attachListener(editor.focusedProperty(), (ov, wasFocused, isFocused) -> { if (wasFocused) { try {
/** * {@inheritDoc} */ @Override protected void initView() { super.initView(); node().setStyle("-fx-background-color:white"); node().setPadding(new Insets(10, 20, 10, 20)); node().setSpacing(40); node().setAlignment(Pos.CENTER); this.selectAll = new CheckBox(); this.todoText = new TextField(); this.todoText.setPrefWidth(Integer.MAX_VALUE); HBox.setHgrow(this.todoText, Priority.ALWAYS); node().getChildren().addAll(this.selectAll, this.todoText); this.todoText.focusedProperty().addListener(this::textFocused); }
public void initialize() { urlField.focusedProperty().addListener((ov, oldValue, newValue) -> { if (newValue) { urlField.textProperty().unbind();