java url encord,Java TextField.setText方法代碼示例

本文整理匯總了Java中javafx.scene.control.TextField.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextField.setText方法的具體用法?Java TextField.setText怎麽用?Java TextField.setText使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.TextField的用法示例。

在下文中一共展示了TextField.setText方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: VisionControl

​點讚 3

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,

示例2: bind

​點讚 3

import javafx.scene.control.TextField; //導入方法依賴的package包/類

public static void bind(TextField textField, ObjectProperty value, StringConverter 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,

示例3: incOrDecFieldValue

​點讚 3

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,

示例4: processSelection

​點讚 3

import javafx.scene.control.TextField; //導入方法依賴的package包/類

/**

* Handle the new selected item.

*

* @param newValue the new selected item.

*/

@FXThread

protected void processSelection(@Nullable final TreeItem 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,

示例5: renameInter

​點讚 3

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() {

@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() {

@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,

示例6: reload

​點讚 3

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,

示例7: maximumChunkSizeSelection

​點讚 3

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,

示例8: timeoutSelection

​點讚 3

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,

示例9: processRemoveClassesFolder

​點讚 2

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,

示例10: createNameField

​點讚 2

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,

示例11: FileSelectorInput

​點讚 2

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> 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,

示例12: HomeTab

​點讚 2

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,

示例13: reload

​點讚 2

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,

示例14: processRemoveEF

​點讚 2

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,

示例15: setValues

​點讚 2

import javafx.scene.control.TextField; //導入方法依賴的package包/類

private static void setValues(TextField field, String value){

if(value!=""){

field.setText(value);

}

}

開發者ID:symphonicon,項目名稱:Fav-Track,代碼行數:6,

示例16: showFileMovableDialog

​點讚 2

import javafx.scene.control.TextField; //導入方法依賴的package包/類

public Pair showFileMovableDialog(String bucket, String key, boolean setKey) {

MainWindowController main = MainWindowController.getInstance();

ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);

Dialog dialog = getDialog(ok);

TextField keyTextField = new TextField();

keyTextField.setPrefWidth(300);

keyTextField.setPromptText(Values.FILE_NAME);

keyTextField.setText(key);

ComboBox bucketCombo = new ComboBox();

bucketCombo.getItems().addAll(main.bucketChoiceCombo.getItems());

bucketCombo.setValue(bucket);

CheckBox copyasCheckBox = new CheckBox(Values.COPY_AS);

copyasCheckBox.setSelected(true);

GridPane grid = getGridPane();

grid.add(copyasCheckBox, 0, 0, 2, 1);

grid.add(new Label(Values.BUCKET_NAME), 0, 1);

grid.add(bucketCombo, 1, 1);

if (setKey) {

grid.add(new Label(Values.FILE_NAME), 0, 2);

grid.add(keyTextField, 1, 2);

Platform.runLater(() -> keyTextField.requestFocus());

}

dialog.getDialogPane().setContent(grid);

dialog.setResultConverter(dialogButton -> {

if (dialogButton == ok) {

return new String[] { bucketCombo.getValue(), keyTextField.getText() };

}

return null;

});

Optional result = dialog.showAndWait();

if (result.isPresent()) {

bucket = bucketCombo.getValue();

key = keyTextField.getText();

FileAction action = copyasCheckBox.isSelected() ? FileAction.COPY : FileAction.MOVE;

return new Pair(action, new String[] { bucket, key });

} else {

return null;

}

}

開發者ID:zhazhapan,項目名稱:qiniu,代碼行數:44,

示例17: ConnDialogResult

​點讚 2

import javafx.scene.control.TextField; //導入方法依賴的package包/類

public static Optional> ConnDialogResult() {

Dialog> dialog = new Dialog<>();

dialog.setTitle("建立連接");

dialog.setHeaderText("請輸入服務器的連接信息");

ButtonType loginButtonType = new ButtonType("連接", ButtonBar.ButtonData.OK_DONE);

dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

// Create the username and password labels and fields.

GridPane grid = new GridPane();

grid.setHgap(10);

grid.setVgap(10);

grid.setPadding(new Insets(20, 150, 10, 10));

TextField hostName = new TextField();

hostName.setPromptText("localhost");

hostName.setText("localhost");

TextField port = new TextField();

port.setPromptText("30232");

port.setText("30232");

grid.add(new Label("主機名: "), 0, 0);

grid.add(hostName, 1, 0);

grid.add(new Label("端口號: "), 0, 1);

grid.add(port, 1, 1);

// Enable/Disable login button depending on whether a username was entered.

// Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);

// loginButton.setDisable(true);

// Do some validation (using the Java 8 lambda syntax).

// hostName.textProperty().addListener((observable, oldValue, newValue) -> {

// loginButton.setDisable(newValue.trim().isEmpty());

// });

dialog.getDialogPane().setContent(grid);

// Request focus on the username field by default.

Platform.runLater(() -> hostName.requestFocus());

dialog.setResultConverter(dialogButton -> {

if (dialogButton == loginButtonType) {

return new Pair<>(hostName.getText(), port.getText());

}

return null;

});

return dialog.showAndWait();

}

開發者ID:bitkylin,項目名稱:ClusterDeviceControlPlatform,代碼行數:51,

示例18: checkWord

​點讚 2

import javafx.scene.control.TextField; //導入方法依賴的package包/類

@FXML

public void checkWord() {

Letter letter = getLetter();

if (letter == null) {

return;

}

// Получаем слово для проверки

String s = word.getText().trim().toUpperCase();

if (lines.contains(s)) {

System.out.println("Нашли слово \"" + s + "\" в словаре");

if (s.contains(letter.text)) {

System.out.println("\"" + letter.text + "\" есть в слове \"" + s + "\"");

boolean[][] used = new boolean[rows][cols];

char curLetter = letter.text.charAt(0);

game[letter.row][letter.col] = curLetter;

boolean found = false;

for (int r = 0; r < rows && !found; r++) {

for (int c = 0; c < cols && !found; c++) {

// Ищем слово с каждой клеточки

if (wordFound(s, 0, r, c, used)) {

found = true;

}

}

}

if (found) {

// Получаем клеточку с буквой

TextField field = gameCells[letter.row][letter.col];

field.setVisible(false); // Скрываем её

field.setText(""); // Очищаем текст

fixedLetter(letter.text.charAt(0), letter.row, letter.col);

// Расставляем вокруг пустые клеточки если их нет

addLetterTextFields();

} else {

System.out.println("Word not found " + s);

game[letter.row][letter.col] = ' ';

}

}

} else {

System.out.println("Не нашли слово \"" + s + "\" в словаре");

}

}

開發者ID:TMihis,項目名稱:Balda,代碼行數:48,

示例19: HeaderPanel

​點讚 2

import javafx.scene.control.TextField; //導入方法依賴的package包/類

public HeaderPanel(AppSession session) {

this.session = session;

content = new HBox(5);

content.setPadding(new Insets(5));

setCenter(content);

textContent = new TextArea();

textContent.setPrefRowCount(16);

textContent.setVisible(false);

setBottom(textContent);

textContent.setManaged(false);

textContent.setFont(App.getDefaultFont());

textContent.focusedProperty().addListener((val, before, after) -> {

if (!after) { // if we lost focus

rebuildFeatureIfTextChanged();

}

});

MenuBar menuBar = new MenuBar();

Menu fileMenu = new Menu("File");

openFileMenuItem = new MenuItem("Open");

fileMenu.getItems().addAll(openFileMenuItem);

Menu importMenu = new Menu("Import");

openImportMenuItem = new MenuItem("Open");

importMenu.getItems().addAll(openImportMenuItem);

menuBar.getMenus().addAll(fileMenu, importMenu);

setTop(menuBar);

if (session != null) {

Label envLabel = new Label("karate.env");

envLabel.setPadding(new Insets(5, 0, 0, 0));

TextField envTextField = new TextField();

envTextField.setText(session.getEnv().env);

Button envButton = new Button("Reset");

envButton.setOnAction(e -> session.resetAll(envTextField.getText()));

Button runAllButton = new Button("Run ►►");

runAllButton.setOnAction(e -> session.runAll());

Button showContentButton = new Button(getContentButtonText(false));

initTextContent();

showContentButton.setOnAction(e -> {

boolean visible = !textContent.isVisible();

textContent.setVisible(visible);

textContent.setManaged(visible);

showContentButton.setText(getContentButtonText(visible));

});

content.getChildren().addAll(envLabel, envTextField, envButton, runAllButton, showContentButton);

}

}

開發者ID:intuit,項目名稱:karate,代碼行數:49,

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值