本文整理汇总了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;
}
}
示例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());
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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());
}
}
示例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());
}
}