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


Java TextField.setOnKeyReleased方法代码示例

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


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

示例1: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                    + "StringConverter is null. Be sure to set a StringConverter "
                    + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
 
开发者ID:Naoghuman,项目名称:ABC-List,代码行数:24,代码来源:CellUtils.java

示例2: refreshView

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public void refreshView ()
{
	renameLayout.getChildren().clear();
	doorname="";
	if(getFXController().getLastViewName().matches("views.StackView.*"))
	{
		doorname = getMyModel().getDataList("").get(getMyModel().getDataList("").size()-1);
	}
	
		oldValue = getMyModel().getString("");
		TextField front = new TextField(getMyModel().getString(""));
		front.setPromptText("Eingabe erforderlich");

		Button saveBtn = new Button("Speichern"); // \u270d \u2055 \u2699 \u270E
		saveBtn.setId("small");
		saveBtn.setOnAction(e ->
		{		
			saveNameAndExit(oldValue, front.getText(), doorname);
		});
		saveBtn.setOnKeyReleased(e ->
		{
			if (e.getCode() == KeyCode.ENTER)
				saveNameAndExit(oldValue, front.getText(), doorname);
		});
		
		front.setOnKeyReleased(e ->
		{
			if (e.getCode() == KeyCode.ENTER)
			{
				saveNameAndExit(oldValue, front.getText(), doorname);
			}		
		});

		renameLayout.getChildren().addAll(front, saveBtn);
	
	scroller.setContent(renameLayout);
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:39,代码来源:RenameView.java

示例3: simpleString

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Kleines Fenster, dass Input (String) vom User abfragt.
 * 
 * @param title
 *            Der Titel des Fensters
 * @param message
 *            Die Narchricht, die angezeigt wird. Text wird nicht von selbst
 *            gewrapt.
 * @param fieldWidth
 *            Setzt die Breite des Textfeldes
 * @return String mit dem Userinput
 */
public static String simpleString (String title, String message, String field, double fieldWidth)
{
	Stage window = buildWindow(title);

	Label l = new Label(message);

	TextField tf = new TextField(field);
	tf.setMaxWidth(fieldWidth);

	tf.setOnKeyReleased(e -> {
		if (e.getCode().equals(KeyCode.ENTER))
		{
			tempOutput = tf.getText();
			window.close();
		}
	});
	
	Button b = new Button("_OK");
	b.setOnAction(e ->
	{
		tempOutput = tf.getText();
		window.close();
	});

	VBox layout = new VBox(20);
	layout.getChildren().addAll(l, tf, b);
	layout.setAlignment(Pos.CENTER);
	layout.setPadding(new Insets(20));

	int width;
	int x = 6;
	int y = 150;

	width = message.length() * x + y;
	
	layout.setOnKeyReleased(e ->
	{
		if (e.getCode() == KeyCode.ESCAPE)
			window.close();
	});
	
	window.setScene(new Scene(layout, width, 150));
	window.showAndWait();
	output = tempOutput;
	tempOutput = null;
	return output;
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:60,代码来源:Alert.java

示例4: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void createTextField() {
    textField = new TextField(getString());
    textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    textField.setOnKeyReleased(new EventHandler<KeyEvent>() {                
        @Override public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                commitEdit(textField.getText());
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:TableCellFactorySample.java

示例5: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void createTextField() {
    textField = new TextField(getString());
    textField.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                Resource value = getTreeItem().getValue();
                File file = new File(((FolderResource) value.getParent()).getFilePath().toFile(), textField.getText());
                if (file.exists()) {
                    FXUIUtils.showMessageDialog(null, "File " + file.getName() + " already exists", null, AlertType.ERROR);
                    cancelEdit();
                    return;
                }
                Resource renamed = value.rename(textField.getText());
                if (renamed != null) {
                    commitEdit(renamed);
                    Resource parent = (Resource) value.getParent();
                    if (parent != null) {
                        int index = parent.getChildren().indexOf(value);
                        parent.getChildren().remove(index);
                        parent.getChildren().add(index, renamed);
                    }
                } else {
                    cancelEdit();
                }
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:ResourceView.java

示例6: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void createTextField() {
    textField = new TextField(getString());
    textField.setOnKeyReleased((KeyEvent t) -> {
        if (t.getCode() == KeyCode.ENTER) {
            commitEdit(textField.getText());
        } else if (t.getCode() == KeyCode.ESCAPE) {
            cancelEdit();
        }
    });  
    
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:TreeViewSample.java

示例7: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void createTextField() {
	textField = new TextField(getString());
	textField.setOnKeyReleased((KeyEvent t) -> {
		if (t.getCode() == KeyCode.ENTER) {
			commitEdit(textField.getText());
		} else if (t.getCode() == KeyCode.ESCAPE) {
			cancelEdit();
		}
	});

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:LabelSample.java

示例8: createComponents

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
@FXThread
protected void createComponents(@NotNull final HBox container) {
    super.createComponents(container);

    valueField = new TextField();
    valueField.setOnKeyReleased(this::updateValue);
    valueField.prefWidthProperty()
            .bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FXUtils.addClassTo(valueField, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
    FXUtils.addToPane(valueField, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:14,代码来源:FloatArrayPropertyControl.java

示例9: createComponents

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
@FXThread
protected void createComponents(@NotNull final HBox container) {
    super.createComponents(container);

    valueField = new TextField();
    valueField.setOnKeyReleased(this::updateValue);
    valueField.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));

    FXUtils.addClassTo(valueField, CSSClasses.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
    FXUtils.addToPane(valueField, container);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:StringPropertyControl.java

示例10: createEditableControl

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
protected TextField createEditableControl() {

    final TextField textField = new TextField();
    textField.setOnScroll(this::processScroll);
    textField.prefWidthProperty().bind(widthProperty().multiply(0.35));
    textField.setOnKeyReleased(this::processChange);

    FXUtils.addClassTo(textField, CSSClasses.ABSTRACT_PARAM_CONTROL_VECTOR2F_FIELD);

    return textField;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:AlphaInterpolationElement.java

示例11: init

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@Override
public void init() throws Exception {

    //Load the image files for all of the
    TextProc.loadImages();
    txtField = new TextField();
    pane = new BorderPane();
    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();

    // Initialize a canvas that is half the size of the screen
    canvas = new Canvas(screenBounds.getWidth() / 2,screenBounds.getHeight() / 2);

    GraphicsContext gc =  canvas.getGraphicsContext2D();


    pane.setCenter(canvas);
    pane.setBottom(txtField);

    // Event handler for the text field. The action is triggered whenever ENTER key is pressed
    txtField.setOnKeyReleased(event -> drawStrokes(txtField.getText(), gc));

}
 
开发者ID:squablyScientist,项目名称:Pitman-Translator,代码行数:23,代码来源:Scratchpad.java

示例12: openEditor

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void openEditor() {

        final PopOver popOver = new PopOver();
        final TextField textEditor = new TextField(targetText.getText());
        BorderPane editorPane = new BorderPane(textEditor);

        BorderPane.setMargin(textEditor, new Insets(12));
        textEditor.setOnKeyReleased(e -> {
            if ( KeyCode.ESCAPE.equals(e.getCode()) ) {
                popOver.hide();
            }
        });
        textEditor.setOnAction(e -> {
            try {
                setTargetValue(Double.parseDouble(textEditor.getText()));
                fireTargeValueSet();
            } catch ( NumberFormatException nfex ) {
                Toolkit.getDefaultToolkit().beep();
            } finally {
                popOver.hide();
            }
        });

        popOver.setContentNode(editorPane);
        popOver.setDetachable(false);
        popOver.setDetached(false);
        popOver.setArrowLocation(PopOver.ArrowLocation.TOP_CENTER);
        popOver.setHeaderAlwaysVisible(true);
        popOver.setHideOnEscape(true);
        popOver.setTitle("Set Target Value");
        popOver.setAnimated(true);
        popOver.setAutoHide(true);
        popOver.setCloseButtonEnabled(true);

        text.getScene().getStylesheets().stream().forEach(s -> popOver.getRoot().getStylesheets().add(s));

        Bounds bounds = getBoundsInLocal();
        Bounds screenBounds = localToScreen(bounds);
        int x = (int) screenBounds.getMinX();
        int y = (int) screenBounds.getMinY();
        int w = (int) screenBounds.getWidth();
        int h = (int) screenBounds.getHeight();

        popOver.show(this, x + w / 2, y + h / 2);
        
    }
 
开发者ID:ESSICS,项目名称:KNOBS,代码行数:47,代码来源:Knob.java


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