javafx.scene.control.TextField#selectAll ( )源码实例Demo

下面列出了javafx.scene.control.TextField#selectAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tcMenu   文件: CreatorEditingTableCell.java
@Override
public void startEdit() {
    super.startEdit();
    createIfNeeded();
    setGraphic(editorNode);
    setText(null);
    CreatorProperty property = getTableRow().getItem();
    if(property.getValidationRules().hasChoices()) {
        ComboBox<String> comboBox = (ComboBox) editorNode;
        comboBox.getSelectionModel().select(property.getLatestValue());
        comboBox.requestFocus();
    }
    else {
        TextField textField = (TextField) editorNode;
        textField.selectAll();
        textField.requestFocus();
    }
}
 
源代码2 项目: ARMStrong   文件: CellUtils.java
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
源代码3 项目: phoebus   文件: CellUtiles.java
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    textField.setText(getItemText(cell, converter));
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
源代码4 项目: AsciidocFX   文件: DialogBuilder.java
public static DialogBuilder newJumpLineDialog() {
    DialogBuilder dialog = new DialogBuilder("", "Goto line/column ");
    dialog.setToolTip("Enter line:column");
    dialog.setKeyReleaseEvent(LINE_COLUMN_REGEX);
    TextField editor = dialog.getEditor();
    editor.setText("0:0");
    editor.selectAll();
    editor.requestFocus();
    return dialog;
}
 
源代码5 项目: phoebus   文件: SelectedWidgetUITracker.java
/** Create an inline editor
 *
 *  <p>Depending on the widget's properties, it will edit
 *  the PV name or the text.
 *
 *  @param widget Widget on which to create an inline editor
 */
private void createInlineEditor(final Widget widget)
{
    // Check for an inline-editable property
    Optional<WidgetProperty<String>> check;

    // Defaulting to PV name or text property with some hard-coded exceptions.
    // Alternative if the list of hard-coded widgets grows:
    // Add Widget#getInlineEditableProperty()
    if (widget instanceof ActionButtonWidget)
        check = Optional.of(((ActionButtonWidget) widget).propText());
    else if (widget instanceof GroupWidget)
        check = Optional.of(((GroupWidget) widget).propName());
    else
        check = widget.checkProperty(CommonWidgetProperties.propPVName);
    if (! check.isPresent())
        check = widget.checkProperty(CommonWidgetProperties.propText);
    if (! check.isPresent())
        return;

    // Create text field, aligned with widget, but assert minimum size
    final MacroizedWidgetProperty<String> property = (MacroizedWidgetProperty<String>)check.get();
    inline_editor = new TextField(property.getSpecification());
    // 'Managed' text field would assume some default size,
    // but we set the exact size in here
    inline_editor.setManaged(false);
    inline_editor.setPromptText(property.getDescription()); // Not really shown since TextField will have focus
    inline_editor.setTooltip(new Tooltip(property.getDescription()));
    inline_editor.relocate(tracker.getX(), tracker.getY());
    inline_editor.resize(Math.max(100, tracker.getWidth()), Math.max(20, tracker.getHeight()));
    getChildren().add(inline_editor);

    // Add autocomplete menu if editing property PVName
    if (property.getName().equals(CommonWidgetProperties.propPVName.getName()))
        PVAutocompleteMenu.INSTANCE.attachField(inline_editor);

    // On enter or lost focus, update the property. On Escape, just close.
    final ChangeListener<? super Boolean> focused_listener = (prop, old, focused) ->
    {
        if (! focused)
        {
            if (!property.getSpecification().equals(inline_editor.getText()))
                undo.execute(new SetMacroizedWidgetPropertyAction(property, inline_editor.getText()));
            // Close when focus lost
            closeInlineEditor();
        }
    };

    inline_editor.setOnAction(event ->
    {
        undo.execute(new SetMacroizedWidgetPropertyAction(property, inline_editor.getText()));
        inline_editor.focusedProperty().removeListener(focused_listener);
        closeInlineEditor();
    });

    inline_editor.setOnKeyPressed(event ->
    {
        switch (event.getCode())
        {
        case ESCAPE:
            event.consume();
            inline_editor.focusedProperty().removeListener(focused_listener);
            closeInlineEditor();
        default:
        }
    });

    inline_editor.focusedProperty().addListener(focused_listener);

    inline_editor.selectAll();
    inline_editor.requestFocus();
}
 
源代码6 项目: phoebus   文件: PVTable.java
@Override
public void startEdit()
{
    super.startEdit();
    if (! isEditing())
        return;

    setText(null);

    final TableItemProxy proxy = getTableView().getItems().get(getIndex());
    final VType value = proxy.getItem().getValue();
    if (value instanceof VEnum)
    {
        // Use combo for Enum-valued data
        final VEnum enumerated = (VEnum) value;
        final ComboBox<String> combo = new ComboBox<>();
        combo.getItems().addAll(enumerated.getDisplay().getChoices());
        combo.getSelectionModel().select(enumerated.getIndex());

        combo.setOnAction(event ->
        {
            // Need to write String, using the enum index
            commitEdit(Integer.toString(combo.getSelectionModel().getSelectedIndex()));
            event.consume();
        });
        combo.setOnKeyReleased(event ->
        {
            if (event.getCode() == KeyCode.ESCAPE)
            {
                cancelEdit();
                event.consume();
            }
        });
        setGraphic(combo);
        Platform.runLater(() -> combo.requestFocus());
        Platform.runLater(() -> combo.show());
    }
    else
    {
        final TextField text_field = new TextField(getItem());
        text_field.setOnAction(event ->
        {
            commitEdit(text_field.getText());
            event.consume();
        });
        text_field.setOnKeyReleased(event ->
        {
            if (event.getCode() == KeyCode.ESCAPE)
            {
                cancelEdit();
                event.consume();
            }
        });
        setGraphic(text_field);
        text_field.selectAll();
        text_field.requestFocus();
    }
}