private Object validateComboBox(Object text) { if (control instanceof ComboBox && ((ComboBox) control).isEditable()) { final String editorText = ((ComboBox<?>) control).getEditor().getText(); text = editorText == null || editorText.isEmpty() ? null : text; } return text; }
private Object validateComboBox(Object text) { if (control instanceof ComboBox && ((ComboBox) control).isEditable()) { final String editorText = ((ComboBox<?>) control).getEditor().getText(); text = editorText == null || editorText.isEmpty() ? null : text; } return text; }
/** * This will install an {@link EventHandler} that monitors the * {@link KeyEvent} events to enable the "prefix selection" feature. * The {@link EventHandler} will only be installed if the {@link ComboBox} * is <b>not</b> editable. * * @param comboBox * The {@link ComboBox} that should be customized * * @see PrefixSelectionCustomizer */ public static void customize(ComboBox<?> comboBox) { if (!comboBox.isEditable()) { comboBox.addEventHandler(KeyEvent.KEY_PRESSED, handler); } comboBox.editableProperty().addListener((o, oV, nV) -> { if (!nV) { comboBox.addEventHandler(KeyEvent.KEY_PRESSED, handler); } else { comboBox.removeEventHandler(KeyEvent.KEY_PRESSED, handler); } }); }
@Override public void configure(T control) { super.configure(control); control.getProperties().put(PrefixSelectionFeature.ENABLED, ""); new PrefixSelectionFeature<>(control, () -> !control.isEditable(), control::getItems, control.getConverter(), index -> control.getSelectionModel().select(index)) .configure(); }
public AquaComboBoxListViewSkin(ComboBox<T> comboBox) { super(comboBox); registerChangeListener(comboBox.disabledProperty(), "DISABLED"); if (getSkinnable().isFocused()) { setFocusBorder(); } else if (!getSkinnable().isFocused() && !getSkinnable().isDisabled()) { setDropShadow(); } for (Object child : getChildren()) { ((Node) child).focusedProperty().addListener(focusListener); } if (comboBox.isEditable()) { getDisplayNode().focusedProperty().addListener(focusListener); } getSkinnable().focusedProperty().addListener(focusListener); }