private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); try { editorProperty(); Field editorField = DatePicker.class.getDeclaredField("editor"); editorField.setAccessible(true); ReadOnlyObjectWrapper<TextField> editor = (ReadOnlyObjectWrapper<TextField>) editorField.get(this); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } }
this.jfxDatePicker = datePicker; try { Field helper = datePicker.focusedProperty().getClass().getSuperclass() .getDeclaredField("helper"); helper.setAccessible(true); ExpressionHelper value = (ExpressionHelper) helper.get(datePicker.focusedProperty()); Field changeListenersField = value.getClass().getDeclaredField("changeListeners"); changeListenersField.setAccessible(true); datePicker.focusedProperty().removeListener(changeListeners[i]); break; datePicker.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null && !newVal) { setTextFromTextFieldIntoComboBoxValue();
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); editorProperty(); ReadOnlyObjectWrapper<TextField> editor = ReflectionHelper.getFieldContent(DatePicker.class, this, "editor" ); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); }
this.jfxDatePicker = datePicker; datePicker.focusedProperty().addListener(observable -> { if (getEditor() != null && !datePicker.isFocused()) { reflectSetTextFromTextFieldIntoComboBoxValue();