本文整理汇总了Java中javafx.scene.control.TextInputControl类的典型用法代码示例。如果您正苦于以下问题:Java TextInputControl类的具体用法?Java TextInputControl怎么用?Java TextInputControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextInputControl类属于javafx.scene.control包,在下文中一共展示了TextInputControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: makeOnButtonDownListener
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
private EventHandler<MouseEvent> makeOnButtonDownListener(){
return new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if(event.getButton() == MouseButton.PRIMARY){
HitInfo i = DnDTextInput.getHitInfo((TextInputControl) event.getSource(), event);
IndexRange r = textInput.getSelection();
if(DnDTextInput.isInRange(i.getInsertionIndex(), r)){
currentSelection = r;
}
inClick = true;
}
}
};
}
示例3: 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());
}
示例4: ctrlBackspaceTest
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
private void ctrlBackspaceTest() {
taTesting = getScene().as(org.jemmy.interfaces.Parent.class, Node.class).lookup(new ByID<TextInputControl>(TextAreaApp.INPUT_AREA_ID + Pages.CtrlBackspaceTest.name())).wrap();
click(taTesting);
end();
String text = getTextFromControl();
final String initialText = text;
while (!"".equals(text)) {
text = deleteLastWord(text);
taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.BACK_SPACE, CTRL);
if (isPasswordField()) {
Assert.assertEquals(initialText, getTextFromControl());
} else {
if (!text.equals(getTextFromControl())) {
out(initialText, text);
}
Assert.assertEquals(text, getTextFromControl());
}
}
}
示例5: ctrlDeleteTest
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
private void ctrlDeleteTest() {
taTesting = getScene().as(org.jemmy.interfaces.Parent.class, Node.class).lookup(new ByID<TextInputControl>(TextAreaApp.INPUT_AREA_ID + Pages.CtrlDeleteTest.name())).wrap();
click(taTesting);
home();
String text = getTextFromControl();
final String initialText = text;
while (!"".equals(text)) {
text = deleteFirstWord(text, true);
taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.DELETE, CTRL);
if (isPasswordField()) {
Assert.assertEquals(initialText, getTextFromControl());
} else {
if (!text.equals(getTextFromControl())) {
out(initialText, text);
}
Assert.assertEquals(text, getTextFromControl());
}
}
}
示例6: getMenuItem
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
protected Wrap<? extends Node> getMenuItem(final String menu) {
getScene().mouse().click();
Parent<Node> parent = getScene().as(Parent.class, Node.class);
final Wrap<? extends TextInputControl> wrap = parent.lookup(TextInputControl.class).wrap();
wrap.mouse().click(1, wrap.getClickPoint(), MouseButtons.BUTTON3);
Wrap<? extends Scene> scene_wrap = PopupMenuTest.getPopupSceneWrap();
Wrap<? extends Node> menu_item = scene_wrap.as(Parent.class, Node.class).lookup(Node.class, new LookupCriteria<Node>() {
public boolean check(Node node) {
if (node.getProperties().containsKey(MenuItem.class)) {
String text = ((MenuItem) node.getProperties().get(MenuItem.class)).getText();
if (text != null && text.contentEquals(menu)) {
return true;
}
}
return false;
}
}).wrap();
return menu_item;
}
示例7: asTest
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
@Test
public void asTest() {
TextInputControlWrap<? extends TextInputControl> area = new TextInputControlDock(new SceneDock().asParent(),
TextArea.class).wrap();
assertTrue(area.is(Text.class));
area.as(Text.class).clear();
area.as(Text.class).type("as text");
assertTrue(area.is(CaretText.class));
area.as(CaretText.class).clear();
area.as(CaretText.class).type("as caret text");
area.as(CaretText.class).to("as", false);
assertTrue(area.is(SelectionText.class));
area.as(SelectionText.class).clear();
area.as(SelectionText.class).type("as selection text");
area.as(SelectionText.class).select("s[^ ]*n");
assertFalse(area.is(SubSelectionText.class));
try {
area.as(SubSelectionText.class).clear();
fail("");
} catch (InterfaceException e) {
//expected
}
}
示例8: setAccelerator
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
/**
* Sets the accelerator of a MenuItem.
* @param keyCombination the KeyCombination value of the accelerator
*/
private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
menuItem.setAccelerator(keyCombination);
/*
* TODO: the code below can be removed once the bug reported here
* https://bugs.openjdk.java.net/browse/JDK-8131666
* is fixed in later version of SDK.
*
* According to the bug report, TextInputControl (TextField, TextArea) will
* consume function-key events. Because CommandBox contains a TextField, and
* ResultDisplay contains a TextArea, thus some accelerators (e.g F1) will
* not work when the focus is in them because the key event is consumed by
* the TextInputControl(s).
*
* For now, we add following event filter to capture such key events and open
* help window purposely so to support accelerators even when focus is
* in CommandBox or ResultDisplay.
*/
getRoot().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (event.getTarget() instanceof TextInputControl && keyCombination.match(event)) {
menuItem.getOnAction().handle(new ActionEvent());
event.consume();
}
});
}
示例9: TextCellEditorHandler
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
/**
* Creates a new instance of {@link TextCellEditorHandler}.
*
* @param pCellEditor the cell editor.
* @param pCellEditorListener the cell editor listener.
* @param pTextComponent the text component.
* @param pDataRow the data row.
* @param pColumnName the column name.
*/
public TextCellEditorHandler(FXTextCellEditor pCellEditor, ICellEditorListener pCellEditorListener, TextInputControl pTextComponent, IDataRow pDataRow, String pColumnName)
{
super(pCellEditor, pCellEditorListener, pTextComponent, pDataRow, pColumnName);
// TODO Set a dynamic preferred size based on the datatype and hint
// in the column definition.
if (component instanceof TextField)
{
((TextField)component).setPrefColumnCount(10);
}
else if (component instanceof TextArea)
{
((TextArea)component).setPrefColumnCount(12);
((TextArea)component).setPrefRowCount(4);
}
registerFocusChangedListener();
registerKeyEventFilter();
textChangedListener = this::onTextChanged;
}
示例10: removeField
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
/**
* Remove the auto-completed field from the menu's list of monitored
* controls
*/
public void removeField(final TextInputControl control)
{
if (current_field != null && current_field.equals(control))
{
menu.hide();
current_field = null;
}
synchronized (fields)
{
for (ControlWrapper cw : fields)
{
if (cw.field.equals(control))
{
cw.unbind();
fields.remove(cw);
break;
}
}
}
}
示例11: TextInputControlStream
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
TextInputControlStream(final TextInputControl textInputControl, Charset charset) {
this.charset = charset;
this.in = new TextInputControlInputStream(textInputControl);
this.out = new TextInputControlOutputStream(textInputControl);
textInputControl.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
if (e.getCode() == KeyCode.ENTER) {
getIn().enterKeyPressed();
return;
}
if (textInputControl.getCaretPosition() <= getIn().getLastLineBreakIndex()) {
e.consume();
}
});
textInputControl.addEventFilter(KeyEvent.KEY_TYPED, e -> {
if (textInputControl.getCaretPosition() < getIn().getLastLineBreakIndex()) {
e.consume();
}
});
}
示例12: addFocusListener
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
/**
* Adds a FocusListener to Scene and open keyboard on {@link TextInputControl}
*
* @param scene
* {@link Scene} to connect with the keyboard
* @param doNotOpen
* on hidden keyboard do nothing and on showing keyboard move to current component
*
* @see #addGlobalFocusListener()
*/
public void addFocusListener(final Scene scene, boolean doNotOpen) {
registerScene(scene);
scene.focusOwnerProperty().addListener((value, n1, n2) -> {
if (n2 instanceof TextInputControl) {
setVisible(doNotOpen ? Visiblity.POS : Visiblity.SHOW, (TextInputControl) n2);
} else if (n2 instanceof Parent) {
TextInputControl control = findTextInputControl((Parent) n2);
setVisible(
(control != null ? (doNotOpen ? Visiblity.POS : Visiblity.SHOW) : Visiblity.HIDE),
control);
} else {
setVisible(Visiblity.HIDE);
}
});
}
示例13: start
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
public void start(Tab rootLayout, Statblock s, Saveable beSaved) throws Exception {
log.debug("statBlockTab.start called");
stat = s;
this.beSaved = beSaved ;
log.debug("Stat ID:" + s.getID());
setAllTexts(stat);
thingsThatCanChange = new TextInputControl[] {nameText, statBlockText};
nameText.textProperty().addListener(nameListener);
for(TextInputControl c: thingsThatCanChange){
c.setOnKeyReleased(saveEvent);
}
}
示例14: getCText
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
final public String getCText() {
if (node instanceof TextInputControl) {
return null;
}
Object o = getAttributeObject(getComponent(), "text");
if (o == null || !(o instanceof String) || o.equals("")) {
return null;
}
return (String) o;
}
示例15: _clear
import javafx.scene.control.TextInputControl; //导入依赖的package包/类
public void _clear() {
verifyCanInteractWithElement();
if (node instanceof TextInputControl) {
((TextInputControl) node).setText("");
} else {
throw new UnsupportedCommandException("Clear not supported on " + node.getClass().getName(), null);
}
}