当前位置: 首页>>代码示例>>Java>>正文


Java TextInputControl.setText方法代码示例

本文整理汇总了Java中javafx.scene.control.TextInputControl.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputControl.setText方法的具体用法?Java TextInputControl.setText怎么用?Java TextInputControl.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.TextInputControl的用法示例。


在下文中一共展示了TextInputControl.setText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyDefault

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
/**
 * @param input
 *            {@link TextInputControl} where set the default value
 */
public void applyDefault(final TextInputControl input)
{
    try
    {
        settingDefaultOn = input;
        final String defaultText = Stream.of(mask) //
                                         .map(m -> Character.toString(m.getDefault()))
                                         .collect(Collectors.joining());
        input.setText(defaultText);

        final int firstAllowedPosition = IntStream.range(0, mask.length)
                                                  .filter(i -> mask[i].isNavigable())
                                                  .findFirst()
                                                  .orElse(0);
        input.selectRange(firstAllowedPosition, firstAllowedPosition);
    }
    finally
    {
        settingDefaultOn = null;
    }
}
 
开发者ID:ben12,项目名称:infxnity,代码行数:26,代码来源:MaskTextFilter.java

示例2: shouldCallStringDistanceService

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
public @Test void shouldCallStringDistanceService() {
	StringDistanceService spiedService = Resolver.resolve(StringDistanceService.class);
	TextInputControl searchInput = lookup("#searchInput").query();

	// given two recipes, one hidden after a search
	searchInput.setText("HOT");
	clickOn("SEARCH");
	
	assumeNotNull(lookup("Hot Tea").query());
	assumeTrue(lookup("Sandwich").query() == null);

	// when a new search is performed
	searchInput.setText("wich");
	clickOn("SEARCH");
	
	// then the StringDistanceService should be called once for each entry, present or not
	verify(spiedService, times(2)).distance(matches("wich"), any());
}
 
开发者ID:NMSU-SIC-Club,项目名称:JavaFX_Tutorial,代码行数:19,代码来源:RecipeBrowserTests.java

示例3: marathon_select

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public boolean marathon_select(String value) {
    TextInputControl tc = (TextInputControl) getComponent();
    Boolean isCellEditor = (Boolean) tc.getProperties().get("marathon.celleditor");
    tc.setText("");
    if (isCellEditor != null && isCellEditor) {
        super.sendKeys(value, JavaAgentKeys.ENTER);
        Cell cell = (Cell) tc.getProperties().get("marathon.cell");
        cell.commitEdit(value);
    } else {
        super.sendKeys(value);
    }
    return true;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaFXTextInputControlElement.java

示例4: onCaretPosition

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
static void onCaretPosition(TextInputControl textinput,
		Dragboard dragboard) {
	int caret = textinput.getCaretPosition();
	String insert = dragboard.getString();
	
	String t1 = textinput.getText().substring(0, textinput.getCaretPosition());
	String t2 = textinput.getText().substring(textinput.getCaretPosition(), textinput.getText().length());
	textinput.setText(t1 + insert + t2);
	textinput.positionCaret(caret + insert.length());
}
 
开发者ID:coalang-soft,项目名称:dragdropfx,代码行数:11,代码来源:DnDTextInput.java

示例5: onSelectedPosition

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
static void onSelectedPosition(TextInputControl textinput,
		Dragboard dragboard) {
	IndexRange selection = textinput.getSelection();
	String t1 = textinput.getText().substring(0, selection.getStart());
	String t2 = textinput.getText().substring(selection.getEnd(), textinput.getText().length());
	textinput.setText(t1 + dragboard.getString() + t2);
}
 
开发者ID:coalang-soft,项目名称:dragdropfx,代码行数:8,代码来源:DnDTextInput.java

示例6: createUndecoratedEditor

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
@Override
protected Node createUndecoratedEditor() {
    //TODO: CustomValue should be bound to defaultValue until we disable auto for the first time
    final HBox container = new HBox();
    final TextInputControl textInput = getInputControl();
    final CheckBox auto = new CheckBox("Auto");
    final boolean useDefaultValue = value.isEmpty().get() || value.get().equals(defaultValue.get());

    textInput.disableProperty().bind(auto.selectedProperty());
    if (useDefaultValue) {
        textInput.textProperty().bind(defaultValue);
    } else {
        textInput.setText(value.get());
    }
    customValue.bind(textInput.textProperty());

    attachListener(textInput.textProperty(), (ov, o, n) -> {
        if (n == null || n.isEmpty() || n.equalsIgnoreCase(defaultValue.getValue())) {
            value.setValue(null);
        } else {
            value.setValue(n);
        }
    });

    auto.selectedProperty().setValue(useDefaultValue);
    attachListener(auto.selectedProperty(), (ov, o, isAuto)
        -> setTextFieldBehaviour(textInput, isAuto, defaultValue, customValue)
    );

    HBox.setHgrow(textInput, Priority.ALWAYS);
    HBox.setHgrow(auto, Priority.NEVER);
    container.getChildren().addAll(auto, textInput);
    return container;
}
 
开发者ID:speedment,项目名称:speedment,代码行数:35,代码来源:AbstractTextItem.java

示例7: setTextFieldBehaviour

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
private static void setTextFieldBehaviour(TextInputControl text, boolean useDefaultValue, ObservableStringValue defaultValue, StringProperty customValue) {
    if (useDefaultValue) {
        customValue.unbind();
        text.textProperty().bind(defaultValue);
    } else {
        text.textProperty().unbind();
        text.setText(customValue.get());
        customValue.bind(text.textProperty());
    }
}
 
开发者ID:speedment,项目名称:speedment,代码行数:11,代码来源:AbstractTextItem.java

示例8: doActionsInEventThread

import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
@Override
protected void doActionsInEventThread() throws QTasteTestFailException {
    final String value = mData[0].toString();

    if (component instanceof TextInputControl) {
        final TextInputControl t = (TextInputControl) component;
        t.requestFocus();
        t.setText(value);
    } else {
        throw new QTasteTestFailException("JavaGUI-FX cannot set text for such component " + component.getClass().getName());
    }
}
 
开发者ID:qspin,项目名称:qtaste,代码行数:13,代码来源:TextSetter.java


注:本文中的javafx.scene.control.TextInputControl.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。