javafx.scene.control.TextInputControl Java Examples
The following examples show how to use
javafx.scene.control.TextInputControl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
@Test public void reset() { BookmarksLevelComboBox combo = lookup("#bookmarksLevel").queryAs(BookmarksLevelComboBox.class); combo.setValidBookmarkLevels(validLevels); clickOn("#bookmarksLevel").type(KeyCode.DIGIT3).push(KeyCode.ENTER); clickOn("#bookmarksRegexp").write("Chuck"); victim.setValidBookmarkLevels(validLevels); clickOn(combo).type(KeyCode.DIGIT3).push(KeyCode.ENTER); assertEquals("3", combo.getValue()); assertThat(combo.getItems(), hasItems("2", "3", "4", "5", "6", "7", "10")); TextInputControl field = lookup("#bookmarksRegexp").queryTextInputControl(); assertEquals("Chuck", field.getText()); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.resetView()); assertEquals(null, combo.getValue()); assertTrue(combo.getItems().isEmpty()); assertEquals("", field.getText()); }
Example #2
Source File: PasswordValidator.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); hasErrors.set(false); if (!passwordsMatch) { hasErrors.set(true); message.set(Res.get("password.passwordsDoNotMatch")); } else if (text.length() < 8) { hasErrors.set(true); message.set(Res.get("validation.passwordTooShort")); } else if (text.length() > 50) { hasErrors.set(true); message.set(Res.get("validation.passwordTooLong")); } }
Example #3
Source File: AutocompleteMenu.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** Toggle menu on Ctrl-Space * * <p>Called by both the text field and the context menu */ private void toggleMenu(final KeyEvent event) { // For Mac, isShortcutDown() to detect Command-SPACE // seemed natural, but that is already captured by OS // for 'Spotlight Search', // so use Ctrl-Space on all OS if (event.isControlDown() && event.getCode() == KeyCode.SPACE) { if (menu.isShowing()) menu.hide(); else if (event.getSource() instanceof TextField) { final TextInputControl field = (TextInputControl) event.getSource(); // Show menu with current content, // in case we were hiding and are now showing the menu // for the same field, not loosing focus, // menu already populated showMenuForField(field); // Certainly need to perform lookup if menu is empty. // Otherwise, cannot hurt to 'refresh' lookup(field); } event.consume(); } }
Example #4
Source File: TooltipUtilities.java From constellation with Apache License 2.0 | 5 votes |
private static void selectActiveArea(TextInputControl control, List<TooltipProvider.TooltipDefinition> definitions) { int s = Integer.MAX_VALUE; int e = Integer.MIN_VALUE; for (TooltipDefinition definition : definitions) { if (definition.getStart() >= 0 && definition.getStart() < s) { s = definition.getStart(); } if (definition.getFinish() >= 0 && definition.getFinish() > e) { e = definition.getFinish(); } } if (s != Integer.MAX_VALUE && e != Integer.MIN_VALUE) { control.selectRange(s, e); } }
Example #5
Source File: EventRedirector.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
private void redirect(@NotNull final InputEvent event) { final EventTarget target = event.getTarget(); if (target == destination) { return; } else if (target instanceof TextInputControl) { if (event instanceof KeyEvent && UiUtils.isNotHotKey((KeyEvent) event)) { if (Config.DEV_DEBUG_JFX_KEY_INPUT) { LOGGER.debug(this, target, ev -> "Key event was skipped because it was from " + ev); } return; } } final EventType<? extends InputEvent> eventType = event.getEventType(); final FileEditor currentEditor = editorAreaComponent.getCurrentEditor(); if (Config.DEV_DEBUG_JFX_KEY_INPUT) { LOGGER.debug(this, event, notNull(currentEditor), (red, ev, editor) -> "Key event " + ev.getEventType() + " is inside " + editor.isInside(red.getSceneX(), red.getSceneY(), ev.getClass())); } if (currentEditor == null || eventType != KeyEvent.KEY_RELEASED && !currentEditor.isInside(getSceneX(), getSceneY(), event.getClass())) { return; } if (Config.DEV_DEBUG_JFX_KEY_INPUT) { LOGGER.debug(this, event, ev -> "Redirect event " + ev); } Event.fireEvent(destination, event.copyFor(event.getSource(), destination)); }
Example #6
Source File: TextFieldValidator.java From thunder with GNU Affero General Public License v3.0 | 5 votes |
public TextFieldValidator (TextInputControl control, Predicate<String> validator) { this.valid.set(validator.test(control.getText())); apply(control, valid.get()); control.textProperty().addListener((observableValue, prev, current) -> { boolean nowValid = validator.test(current); if (nowValid == valid.get()) { return; } valid.set(nowValid); }); valid.addListener(o -> apply(control, valid.get())); }
Example #7
Source File: TextFieldValidator.java From thunder with GNU Affero General Public License v3.0 | 5 votes |
private static void apply (TextInputControl textField, boolean nowValid) { if (nowValid) { textField.getStyleClass().remove("validation_error"); } else { textField.getStyleClass().add("validation_error"); } }
Example #8
Source File: TextFieldValidator.java From GreenBits with GNU General Public License v3.0 | 5 votes |
public TextFieldValidator(TextInputControl control, Predicate<String> validator) { this.valid.set(validator.test(control.getText())); apply(control, valid.get()); control.textProperty().addListener((observableValue, prev, current) -> { boolean nowValid = validator.test(current); if (nowValid == valid.get()) return; valid.set(nowValid); }); valid.addListener(o -> apply(control, valid.get())); }
Example #9
Source File: TextFieldValidator.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private static void apply(TextInputControl textField, boolean nowValid) { if (nowValid) { textField.getStyleClass().remove("validation_error"); } else { textField.getStyleClass().add("validation_error"); } }
Example #10
Source File: IntegerValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } }
Example #11
Source File: IntegerValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); try { hasErrors.set(false); if (!text.isEmpty()) { Integer.parseInt(text); } } catch (Exception e) { hasErrors.set(true); } }
Example #12
Source File: DoubleValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } }
Example #13
Source File: DoubleValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); try { Double.parseDouble(textField.getText()); hasErrors.set(false); } catch (Exception e) { hasErrors.set(true); } }
Example #14
Source File: RequiredFieldValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } if (srcControl.get() instanceof ComboBoxBase) { evalComboBoxField(); } }
Example #15
Source File: RequiredFieldValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); if (textField.getText() == null || textField.getText().isEmpty()) { hasErrors.set(true); } else { hasErrors.set(false); } }
Example #16
Source File: StringLengthValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } }
Example #17
Source File: StringLengthValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); hasErrors.set(false); if (!text.isEmpty()) { if (text.length() > StringLength - 1) { hasErrors.set(true); // textField.textProperty().set(text.substring(0, 19)); } } }
Example #18
Source File: RegexValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } }
Example #19
Source File: RegexValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = (textField.getText() == null) ? "" : textField.getText(); // Treat null like empty string if (regexPatternCompiled.matcher(text).matches()) { hasErrors.set(false); } else { hasErrors.set(true); } }
Example #20
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void eval() { if (srcControl.get() instanceof TextInputControl) { evalTextInputField(); } }
Example #21
Source File: NumberValidator.java From JFoenix with Apache License 2.0 | 5 votes |
private void evalTextInputField() { TextInputControl textField = (TextInputControl) srcControl.get(); String text = textField.getText(); try { hasErrors.set(false); if (!text.isEmpty()) numberStringConverter.fromString(text); } catch (Exception e) { hasErrors.set(true); } }
Example #22
Source File: TextFieldValidator.java From devcoretalk with GNU General Public License v2.0 | 5 votes |
public TextFieldValidator(TextInputControl control, Predicate<String> validator) { this.valid.set(validator.test(control.getText())); apply(control, valid.get()); control.textProperty().addListener((observableValue, prev, current) -> { boolean nowValid = validator.test(current); if (nowValid == valid.get()) return; valid.set(nowValid); }); valid.addListener(o -> apply(control, valid.get())); }
Example #23
Source File: TextFieldValidator.java From devcoretalk with GNU General Public License v2.0 | 5 votes |
private static void apply(TextInputControl textField, boolean nowValid) { if (nowValid) { textField.getStyleClass().remove("validation_error"); } else { textField.getStyleClass().add("validation_error"); } }
Example #24
Source File: TextFieldValidator.java From thundernetwork with GNU Affero General Public License v3.0 | 5 votes |
public TextFieldValidator(TextInputControl control, Predicate<String> validator) { this.valid.set(validator.test(control.getText())); apply(control, valid.get()); control.textProperty().addListener((observableValue, prev, current) -> { boolean nowValid = validator.test(current); if (nowValid == valid.get()) return; valid.set(nowValid); }); valid.addListener(o -> apply(control, valid.get())); }
Example #25
Source File: TextFieldValidator.java From thundernetwork with GNU Affero General Public License v3.0 | 5 votes |
private static void apply(TextInputControl textField, boolean nowValid) { if (nowValid) { textField.getStyleClass().remove("validation_error"); } else { textField.getStyleClass().add("validation_error"); } }
Example #26
Source File: ProposalDisplay.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public void clearForm() { inputControls.stream().filter(Objects::nonNull).forEach(TextInputControl::clear); if (linkHyperlinkWithIcon != null) linkHyperlinkWithIcon.clear(); comboBoxes.stream().filter(Objects::nonNull).forEach(comboBox -> comboBox.getSelectionModel().clearSelection()); }
Example #27
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void restoreState() { SizeUnitRadio kilo = lookup("#unit" + SizeUnit.KILOBYTE.symbol()).queryAs(SizeUnitRadio.class); SizeUnitRadio mega = lookup("#unit" + SizeUnit.MEGABYTE.symbol()).queryAs(SizeUnitRadio.class); Map<String, String> data = new HashMap<>(); data.put("size", "100"); data.put(SizeUnit.MEGABYTE.toString(), Boolean.TRUE.toString()); victim.restoreStateFrom(data); TextInputControl field = lookup("#sizeField").queryTextInputControl(); assertEquals("100", field.getText()); assertTrue(mega.isSelected()); assertFalse(kilo.isSelected()); }
Example #28
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void reset() { SizeUnitRadio kilo = lookup("#unit" + SizeUnit.KILOBYTE.symbol()).queryAs(SizeUnitRadio.class); clickOn("#sizeField").write("100").push(KeyCode.ENTER); clickOn("#unit" + SizeUnit.KILOBYTE.symbol()); TextInputControl field = lookup("#sizeField").queryTextInputControl(); assertEquals("100", field.getText()); assertTrue(kilo.isSelected()); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.resetView()); assertEquals("", field.getText()); assertFalse(kilo.isSelected()); }
Example #29
Source File: SplitOptionsPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Test public void restoreState() { Map<String, String> data = new HashMap<>(); data.put("regexp", "Chuck"); data.put("levelCombo.selected", "2"); data.put("levelCombo.levels", "2,3,5,6,7,10"); victim.restoreStateFrom(data); TextInputControl field = lookup("#bookmarksRegexp").queryTextInputControl(); assertEquals("Chuck", field.getText()); BookmarksLevelComboBox levelCombo = lookup("#bookmarksLevel").queryAs(BookmarksLevelComboBox.class); assertEquals(6, levelCombo.getItems().size()); assertEquals("2", levelCombo.getSelectionModel().getSelectedItem()); }
Example #30
Source File: MacroizedWidgetPropertyBinding.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public MacroizedWidgetPropertyBinding(final UndoableActionManager undo, final TextInputControl field, final MacroizedWidgetProperty<?> widget_property, final List<Widget> other) { super(undo, field, widget_property, other); }