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


Java TextField.setText方法代码示例

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


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

示例1: VisionControl

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public VisionControl() {
	slider = new Slider();
	slider.setMin(0.0);
	slider.setMax(255.0);
	slider.setValue(0.0);
	slider.setMaxWidth(350.0);
	slider.setDisable(true);
	
	inputText = new TextField();
	inputText.setText("0");
	inputText.setMaxWidth(50.0);
	inputText.setOnKeyPressed((e)->{
		if(e.getCode() == KeyCode.ENTER){
			setTextFromField();
		}
	});
	inputText.focusedProperty().addListener((obs, o, n)->{
		if(!n.booleanValue()){
			inputText.setText(String.valueOf((int)slider.getValue()));
		}
	});
	
	slider.valueProperty().addListener((obs, o, n)->{
		inputText.setText(String.valueOf((int)slider.getValue()));
	});
	
	nameLabel = new Label("");
	
	HBox top = new HBox();
	top.setSpacing(5.0);
	top.getChildren().addAll(nameLabel, inputText);
	
	VBox all = new VBox();
	all.setSpacing(10.0);
	all.getChildren().addAll(top, slider);
	root = all;
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:38,代码来源:MainWindow.java

示例2: bind

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static <T> void bind(TextField textField, ObjectProperty<T> value, StringConverter<T> stringConverter, Runnable onCommit) {
    executeOnFocusLostOrEnter(textField, () -> {
        T oldValue = value.get();
        value.set(stringConverter.fromString(textField.getText()));
        textField.setText(stringConverter.toString(stringConverter.fromString(textField.getText())));
        textField.positionCaret(textField.getLength());
        if (onCommit != null && !Objects.equals(oldValue, value.get())) {
            onCommit.run();
        }
    });
    value.addListener((v, o, n) -> textField.setText(stringConverter.toString(n)));
    textField.setText(stringConverter.toString(value.get()));
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:14,代码来源:TextFieldHelper.java

示例3: incOrDecFieldValue

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void incOrDecFieldValue(KeyEvent e, double x) {

        if (!(e.getSource() instanceof TextField)) {
            return; // check it's a textField
        }        // increment or decrement the value
        final TextField tf = (TextField) e.getSource();
        final Double newValue = Double.valueOf(tf.getText()) + x;
        double rounded = round(newValue, roundingFactor);
        slider_slider.setValue(rounded);
        tf.setText(Double.toString(newValue));
        // Avoid using runLater
        // This should be done somewhere else (need to investigate)
//        Platform.runLater(new Runnable() {
//            @Override
//            public void run() {
//                // position caret after new value for easy editing
//                tf.positionCaret(tf.getText().length());
//            }
//        });
    }
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:21,代码来源:GradientSlider.java

示例4: processSelection

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Handle the new selected item.
 *
 * @param newValue the new selected item.
 */
@FXThread
protected void processSelection(@Nullable final TreeItem<ResourceElement> newValue) {

    if (newValue != null) {

        final TextField fileNameField = getFileNameField();

        final ResourceElement value = newValue.getValue();
        final Path file = value.getFile();

        if (!Files.isDirectory(file)) {
            fileNameField.setText(FileUtils.getNameWithoutExtension(file));
        }
    }

    validateFileName();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:SaveAsEditorDialog.java

示例5: renameInter

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public void renameInter(){
	renameInterview.setDisable(true);
	TextField textField = new TextField();
	textField.setText(interview.getNom());
	textField.setMaxWidth(100);
	textField.requestFocus();
	textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
		 @Override
		    public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
		    {
		        if (!newPropertyValue)
		        {
		        	nomEntretien.setText(textField.getText());
		        	interview.setNom(textField.getText());
					interviewPane.setLeft(nomEntretien);
					renameInterview.setDisable(false);
		        }
		    }
	});
	textField.setOnKeyPressed(new EventHandler<KeyEvent>() {

		@Override
		public void handle(KeyEvent event) {
			if(event.getCode() == KeyCode.ENTER){
				nomEntretien.setText(textField.getText());
				interview.setNom(textField.getText());
				interviewPane.setLeft(nomEntretien);
				renameInterview.setDisable(true);
			}
			if(event.getCode() == KeyCode.ESCAPE){
				interviewPane.setLeft(nomEntretien);
				renameInterview.setDisable(true);
			}
		}
	});
	interviewPane.setLeft(textField);
	Platform.runLater(()->textField.requestFocus());
	Platform.runLater(()->textField.selectAll());
	
}
 
开发者ID:coco35700,项目名称:uPMT,代码行数:41,代码来源:InterviewTreeViewController.java

示例6: reload

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

    final int[] element = getPropertyValue();

    final TextField valueField = getValueField();
    final int caretPosition = valueField.getCaretPosition();

    if (element == null) {
        valueField.setText(StringUtils.EMPTY);
    } else {
        valueField.setText(ArrayUtils.toString(element, " ", false, false));
    }

    valueField.positionCaret(caretPosition);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:IntArrayPropertyControl.java

示例7: maximumChunkSizeSelection

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private Node maximumChunkSizeSelection( ProgrammerSettingDetails settingDetails )
{
	HBox hBox = new HBox();

	//TODO ensure numerical values only
	Text maxChunkSizeLabel = new Text("Maximum chunk size: ");
	maxChunkSizeLabel.setId(UIConstants.TEXT_COLOR);

	TextField maxChunkSizeTextField = new TextField();
	maxChunkSizeTextField.setText(settingDetails.getMaximumChunkSize());

	maxChunkSizeTextField.textProperty().addListener(( observable, oldValue, newValue ) -> {
		if ( !newValue.isEmpty() )
			UIStyle.applyError(VerifyUtil.simpleIntegerCheck(newValue), maxChunkSizeTextField);
	});

	maximumChunkSizeSelectionModel = maxChunkSizeTextField.textProperty();

	hBox.getChildren().addAll(maxChunkSizeLabel, maxChunkSizeTextField);

	return hBox;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:23,代码来源:ProgrammerSettingsPanel.java

示例8: timeoutSelection

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private Node timeoutSelection( ProgrammerSettingDetails settingDetails )
{
	HBox hBox = new HBox();

	Text receiveTimeoutLabel = new Text("Receive timout (ms): ");
	receiveTimeoutLabel.setId(UIConstants.TEXT_COLOR);

	TextField receiveTimeoutTextField = new TextField();
	receiveTimeoutTextField.setText(settingDetails.getReceiveTimeoutMilliseconds());

	receiveTimeoutTextField.textProperty().addListener(( observable, oldValue, newValue ) -> {
		if ( !newValue.isEmpty() )
			UIStyle.applyError(VerifyUtil.simpleIntegerCheck(newValue), receiveTimeoutTextField);
	});

	receiveTimeoutSelectionModel = receiveTimeoutTextField.textProperty();

	hBox.getChildren().addAll(receiveTimeoutLabel, receiveTimeoutTextField);

	return hBox;
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:22,代码来源:ProgrammerSettingsPanel.java

示例9: processRemoveClassesFolder

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Process of removing the additional classpath.
 */
@FXThread
private void processRemoveClassesFolder() {
    setClassesFolder(null);

    final TextField textField = getClassesFolderField();
    textField.setText(StringUtils.EMPTY);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:11,代码来源:SettingsDialog.java

示例10: createNameField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private VBox createNameField() {
    VBox nameFieldBox = new VBox();
    TextField nameField = new TextField();
    nameField.textProperty().addListener((observable, oldValue, newValue) -> {
        fireContentChanged();
        checkList.setName(nameField.getText());
    });
    nameField.setEditable(mode.isSelectable());
    nameFieldBox.getChildren().addAll(new Label("Name"), nameField);
    HBox.setHgrow(nameField, Priority.ALWAYS);
    VBox.setMargin(nameFieldBox, new Insets(5, 10, 0, 5));
    nameField.setText(checkList.getName());
    HBox.setHgrow(nameFieldBox, Priority.ALWAYS);
    return nameFieldBox;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:16,代码来源:CheckListFormNode.java

示例11: FileSelectorInput

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * @param parameterValues List of parameters
 * @param index           Index that this input should use to set its value in the parameters list
 * @param windowNode      A Node that will be used for getting the window to show the FileChooser
 * @param defaultValue    (Optional) Path to a previously-selected file for this input
 */
public FileSelectorInput(List<JPair<String, Object>> parameterValues, int index, Node windowNode, String defaultValue) {
    this.setSpacing(5.0);

    TextField fileField = new TextField();
    fileField.textProperty().addListener((observable, oldValue, newValue)
            -> parameterValues.get(index).setRight(newValue));

    Button browseBtn = new Button("Browse");

    // Setup the button action
    FileChooser fileChooser = new FileChooser();
    browseBtn.onActionProperty().setValue(event -> {
        // Open file chooser
        if (previousFolder != null) {
            fileChooser.setInitialDirectory(previousFolder);
        }
        File file = fileChooser.showOpenDialog(windowNode.getScene().getWindow());

        if (file != null) {
            fileField.textProperty().setValue(file.getAbsolutePath());
            // Save the file's directory to remember it if the FileChooser is opened again
            previousFolder = file.getParentFile();
        }
    });

    // Add nodes to HBox
    this.getChildren().addAll(fileField, browseBtn);

    // If there is a default value, use it
    if (!defaultValue.equals("-")) {
        // Set the value to the text field, which will then update the parameterValues list
        fileField.setText(defaultValue);
    }
}
 
开发者ID:scify,项目名称:jedai-ui,代码行数:41,代码来源:FileSelectorInput.java

示例12: HomeTab

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public HomeTab(Button button, Pane pane, TextField connectionStatus, TextArea console) {
    super(button, pane);
    this.connectionStatus = connectionStatus;
    this.console = console;

    // set connection status to red, because no connection exists
    connectionStatus.setText(NOT_CONNECTED);
    connectionStatus.setStyle("-fx-text-inner-color: red;");

    // register this as event listener
    EventExecutor.getInstance().register(this);
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:13,代码来源:HomeTab.java

示例13: reload

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Reload this element.
 */
public void reload() {

    final AlphaInfluencerControl control = getControl();
    final AlphaInfluencer influencer = control.getInfluencer();

    final Float alpha = influencer.getAlpha(getIndex());

    final TextField editableControl = getEditableControl();
    final int caretPosition = editableControl.getCaretPosition();
    editableControl.setText(alpha.toString());
    editableControl.positionCaret(caretPosition);

    super.reload();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:AlphaInterpolationElement.java

示例14: processRemoveEF

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Process of removing the additional envs.
 */
@FXThread
private void processRemoveEF() {
    setAdditionalEnvsFolder(null);

    final TextField textField = getAdditionalEnvsField();
    textField.setText(StringUtils.EMPTY);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:11,代码来源:SettingsDialog.java

示例15: setValues

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private static void setValues(TextField field, String value){
    if(value!=""){
        field.setText(value);
    }
}
 
开发者ID:symphonicon,项目名称:Fav-Track,代码行数:6,代码来源:loginController.java


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