當前位置: 首頁>>代碼示例>>Java>>正文


Java TextInputControl類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:ben12,項目名稱:infxnity,代碼行數:26,代碼來源:MaskTextFilter.java

示例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;
			}
		}
	};
}
 
開發者ID:coalang-soft,項目名稱:dragdropfx,代碼行數:19,代碼來源:TextDragListenerContext.java

示例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());
}
 
開發者ID:NMSU-SIC-Club,項目名稱:JavaFX_Tutorial,代碼行數:19,代碼來源:RecipeBrowserTests.java

示例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());
        }
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:21,代碼來源:TextInputBase.java

示例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());
        }
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:21,代碼來源:TextInputBase.java

示例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;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:20,代碼來源:TextInputBase.java

示例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
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:24,代碼來源:TextTest.java

示例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();
        }
    });
}
 
開發者ID:se-edu,項目名稱:addressbook-level4,代碼行數:30,代碼來源:MainWindow.java

示例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;
}
 
開發者ID:ivartanian,項目名稱:JVx.javafx,代碼行數:31,代碼來源:FXTextCellEditor.java

示例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;
            }
        }
    }
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:25,代碼來源:AutocompleteMenu.java

示例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();
    }
  });
}
 
開發者ID:uphy,項目名稱:javafx-console,代碼行數:22,代碼來源:TextInputControlStream.java

示例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);
    }
  });
}
 
開發者ID:comtel2000,項目名稱:fx-experience,代碼行數:26,代碼來源:KeyBoardPopup.java

示例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);
	}
}
 
開發者ID:ForJ-Latech,項目名稱:fwm,代碼行數:14,代碼來源:StatBlockTabController.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:JavaFXElementPropertyAccessor.java

示例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);
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:9,代碼來源:JavaFXElement.java


注:本文中的javafx.scene.control.TextInputControl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。