當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。