attachListener(editor.textProperty(), (ov, oldVal, newVal) -> { try { Integer.parseInt(newVal); } catch (final NumberFormatException ex) { editor.setText(oldVal); attachListener(editor.focusedProperty(), (ov, wasFocused, isFocused) -> { if (wasFocused) { try { final int editorValue = Integer.parseInt(editor.getText()); if (editorValue > max) { editor.setText(String.valueOf(max)); } else if (editorValue < min) { editor.setText(String.valueOf(min));
@Override protected Node createUndecoratedEditor() { final TextField box = new TextField( property.get() ); property.bindBidirectional(box.textProperty() ); return box; } }
if (fieldHost.getText().isEmpty() || fieldHost.getText().equals(generatedHost.get())) { fieldHost.textProperty().setValue(DEFAULT_HOST); generatedHost.set(DEFAULT_HOST); fieldUser.setDisable(false); fieldPass.setDisable(false); if (fieldUser.getText().isEmpty() || fieldUser.getText().equals(generatedUser.get())) { fieldUser.textProperty().setValue(DEFAULT_USER); generatedUser.set(DEFAULT_USER); fieldUser.setDisable(true); fieldPass.setDisable(true); fieldName.setDisable(false); if (fieldName.getText().isEmpty() || fieldName.getText().equals(generatedName.get())) { item.getDefaultDbmsName().ifPresent(name -> { fieldName.textProperty().setValue(name); generatedName.set(name); }); fieldName.setDisable(true); fieldSchema.setDisable(false);
public JFXTextFieldSkinAndroid(T textField) { super(textField); textPane = (Pane) this.getChildren().get(0); // get parent fields reflectionFieldConsumer("textNode", field -> textNode = (Node) field.get(this)); reflectionFieldConsumer("textTranslateX", field -> textTranslateX = (DoubleProperty) field.get(this)); linesWrapper = new PromptLinesWrapper<T>( textField, super.promptTextFill, textField.textProperty(), textField.promptTextProperty(), () -> promptText); linesWrapper.init(() -> createPromptNode(), textPane); reflectionFieldConsumer("usePromptText", field -> field.set(this, linesWrapper.usePromptText)); errorContainer = new ValidationPane<>(textField); getChildren().addAll(linesWrapper.line, linesWrapper.focusedLine, linesWrapper.promptContainer, errorContainer); registerChangeListener(textField.disableProperty(), "DISABLE_NODE"); registerChangeListener(textField.focusColorProperty(), "FOCUS_COLOR"); registerChangeListener(textField.unFocusColorProperty(), "UNFOCUS_COLOR"); registerChangeListener(textField.disableAnimationProperty(), "DISABLE_ANIMATION"); }
grid.setPadding(new Insets(20, 150, 10, 10)); final TextField username = new TextField(dbms.getUsername().orElse("Root")); username.setPromptText("Username"); final PasswordField password = new PasswordField(); password.setPromptText("Password"); username.textProperty().addListener((ob, o, n) -> loginButton.setDisable(n.trim().isEmpty()) ); return new Pair<>(username.getText(), password.getText().toCharArray());
@Override public Node createValueVisualisation() { TextField textField = new TextField(); textField.textProperty().bindBidirectional(observableAttributeValue); textField.disableProperty().bind(readOnly); return textField; } }
@Nonnull public static TextField textFieldIntegerReadonly(@Nonnull ReadOnlyIntegerProperty integerProperty, @Nonnull NumberStringConverterForIntegers integerConverter) { TextField textField = new TextField(); integerProperty.addListener((observable, oldValue, newValue) -> textField.setText(integerConverter.toString(newValue))); textField.setText(integerConverter.toString(integerProperty.get())); textField.setEditable(false); return textField; }
public void textFocused(final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) { if (!newValue && this.todoText.getText().isEmpty()) { this.todoText.setText("Enter Something todo"); } else if (newValue && this.todoText.getText().equals("Enter Something todo")) { this.todoText.setText(""); } }
public <T> void bindTextBidirectional(@Nonnull Property<T> property, @Nonnull StringConverter<T> converter) { textField.setOnAction(event -> { property.setValue(converter.fromString(textField.getText())); lastChange = -1; //reset the last change to ensure updates are reflected }); textField.setText(converter.toString(property.getValue())); textField.caretPositionProperty().addListener((observable, oldValue, newValue) -> updateLastChange("caret position changed")); textField.onKeyPressedProperty().addListener((observable, oldValue, newValue) -> updateLastChange("key pressed")); textField.focusedProperty().addListener((observable, oldValue, newValue) -> updateLastChange("focus changed")); textField.selectedTextProperty().addListener((observable, oldValue, newValue) -> updateLastChange("selected text changed")); if (textField.isFocused()) { textField.setText(converter.toString(newValue)); }); textField.textProperty().addListener((observable, oldValue, newValue) -> property.setValue(converter.fromString(newValue))); textField.focusedProperty().addListener((observable, oldValue, newValue) -> { if (!newValue) { textField.setText(converter.toString(property.getValue()));
public static void addNameField(MigPane root, PresentationModel model) { root.add(label(Bundle.fieldsets_label_name())); TextField nameField = new TextField(); nameField.setPrefWidth(PREF_WIDTH); root.add(nameField); JFXBinder.bind(HasName.PROP_NAME).of(Model.withAt(model, HasName.PROP_NAME)).to("text").of(nameField); JFXBinder.bind("text").of(nameField).to(HasName.PROP_NAME).of(model); }
if (filterField.getText() == null || filterField.getText().isEmpty()) return null; return TreeItemPredicate.create(actor -> actor.toString().contains(filterField.getText())); }, filterField.textProperty()));
this.setContent(content); command.getStyleClass().add("consoleCommandType"); consolePane = new ScrollPane(console); content.setBottom(command); command.setOnKeyPressed(event -> { if (event.getCode() == KeyCode.ENTER) { this.onSendCommand.accept(command.getText()); commandHistory.add(new CommandHistory.Item(command.getText(), command.getCaretPosition())); clearCommand(); command.setOnKeyReleased(event -> { if (event.getCode() == KeyCode.UP) { CommandHistory.Item historyItem = commandHistory.up(); command.setText(historyItem.getCommand()); command.positionCaret(historyItem.getCursorPosition()); } else if (event.getCode() == KeyCode.DOWN) { CommandHistory.Item historyItem = commandHistory.down(); command.setText(historyItem.getCommand()); command.positionCaret(historyItem.getCursorPosition()); command.setPromptText("> ");
public TagArea() { this.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); getStyleClass().setAll("tag-area"); textField.setMinSize(80, 30); textField.setPrefWidth(80); textField.setOnAction(event -> { this.addTag(textField.getText()); textField.clear(); }); textField.setOnKeyReleased(event -> { System.out.println("[Pressed] Pressed Key: " + event.getCode() + ", Character is: " + event.getCharacter()); if (event.getCode() == KeyCode.BACK_SPACE && textField.getText().length() == 0) { List<Tag> tags = this.getTags(); if (tags.size() != 0) { Tag lastTag = tags.get(tags.size() - 1); removeTag(lastTag); textField.setText(lastTag.getValue()); textField.positionCaret(lastTag.getValue().length()); event.consume(); } } else if (event.getCode() == KeyCode.COMMA) { System.out.println("TextField value is: " + textField.getText()); addTag(textField.getText().replaceAll(",", "")); textField.clear(); event.consume(); } }); this.getChildren().add(textField); }
public String getValue() { return valueField.getText(); }
setContentDisplay(ContentDisplay.TEXT_ONLY); textField.setOnAction(evt -> { commitEdit(this.converter.fromString(textField.getText())); }); textField.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (!isNowFocused) { commitEdit(this.converter.fromString(textField.getText())); textField.addEventFilter(KeyEvent.KEY_PRESSED, event -> { if (event.getCode() == KeyCode.ESCAPE) { textField.setText(converter.toString(getItem())); cancelEdit(); event.consume();
public void setValue(String value) { valueField.setText(value); }
public static void addCalculatedAreaField(MigPane root, PresentationModel model) { root.add(label(Bundle.fieldsets_label_area_in_ha())); final TextField areaField = new TextField(); areaField.setPrefWidth(FieldSets.PREF_WIDTH); // areaField.setEditable(false); areaField.setDisable(true); root.add(areaField); Model.withAt(model, HasArea.PROP_AREA_IN_HECTARES, HasGeometry.PROP_GEOMETRY); areaField.setText(Double.toString(wktArea(PM.getStringAttr(model, HasGeometry.PROP_GEOMETRY)))); model.getAt(HasGeometry.PROP_GEOMETRY).addPropertyChangeListener(Attribute.VALUE, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent pce) { String wkt = (String) pce.getNewValue(); areaField.setText(Double.toString(wktArea(wkt))); //TODO: round/format } }); //TODO: // - extract rule class tht can be applied to both client and server side models // -use plain binding once area is automatically updated server side: // JFXBinder.bind(HasArea.PROP_AREA_IN_HECTARES).of(model).to("text").of(areaField);// }
searchField.setPromptText( localize(asKey("property.sheet.search.field.prompt"))); //$NON-NLS-1$ searchField.setMinWidth(0); HBox.setHgrow(searchField, Priority.SOMETIMES); searchField.managedProperty().bind(searchField.visibleProperty()); toolbar.getItems().add(searchField); registerChangeListener(control.propertyEditorFactory(), e -> refreshProperties()); registerChangeListener(control.titleFilter(), e -> refreshProperties()); registerChangeListener(searchField.textProperty(), e -> getSkinnable().setTitleFilter(searchField.getText())); registerChangeListener(control.modeSwitcherVisibleProperty(), e -> updateToolbar()); registerChangeListener(control.searchBoxVisibleProperty(), e -> updateToolbar());
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()); } }); }
protected AbstractNodeSelectionPane(String label, Supplier<Optional<T>> nodeChooser, boolean mandatory, GseContext context) { Objects.requireNonNull(label); this.label = new Label(label + ":"); textField.setOnKeyPressed((KeyEvent ke) -> { if (ke.getCode() == KeyCode.DELETE || ke.getCode() == KeyCode.BACK_SPACE) { nodeProperty.setValue(null); textField.textProperty().addListener((observable, oldValue, newValue) -> { if (newValue == null || newValue.isEmpty()) { nodeProperty.setValue(null); textField.setOnKeyTyped(Event::consume); // not editable but still clearable nodeProperty.addListener((observable, oldNode, newNode) -> { if (newNode == null) { textField.setText(""); } else { textField.setDisable(true); button.setDisable(true); textField.setText("..."); GseUtil.execute(context.getExecutor(), () -> { String pathStr; textField.setText(pathStr); textField.setDisable(false); button.setDisable(false); }); if (mandatory) { new ValidationSupport().registerValidator(textField, Validator.createEmptyValidator(RESOURCE_BUNDLE.getString("Mandatory"))); textField.setText(null);