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


Java TextField.getText方法代码示例

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


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

示例1: getCoordinatesCalculatePathShowDirectionsAndHidePanel

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void getCoordinatesCalculatePathShowDirectionsAndHidePanel(final Pane path_choice_pane,
                                                                   final TextField txt_from, final TextField txt_to,
                                                                   final Button btn_get_coords_find_path) {
    final String addressOrigin = txt_from.getText();
    final String addressDestination = txt_to.getText();

    final DirectionsRequest directionsRequest =
            new DirectionsRequest(addressOrigin, addressDestination, TravelModes.DRIVING);

    directionsPane = mapComponent.getDirec(); // TODO: 11/10/2017 IT HAS TO BE CLEARED!
    directionsService = new DirectionsService();
    directionsRenderer = new DirectionsRenderer(true, map, directionsPane);
    directionsService.getRoute(directionsRequest, this, directionsRenderer);

    if (!addressOrigin.equals("") || !addressDestination.equals("")) {
        path_choice_pane.setVisible(false);
        btn_get_coords_find_path.setVisible(false);
    }
}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:20,代码来源:GmapfxController.java

示例2: getFileToSave

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Gets file to create.
 *
 * @return the file to creating.
 */
@FromAnyThread
protected @Nullable Path getFileToSave() {

    final TextField fileNameField = getFileNameField();
    final String filename = fileNameField.getText();
    if (StringUtils.isEmpty(filename)) return null;

    final String fileExtension = getExtension();

    final Path selectedFile = getSelectedFile();
    if (selectedFile == null) return null;

    final Path directory = Files.isDirectory(selectedFile) ? selectedFile : selectedFile.getParent();

    return StringUtils.isEmpty(fileExtension) ? directory.resolve(filename) :
            directory.resolve(filename + "." + fileExtension);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:SaveAsEditorDialog.java

示例3: processScroll

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * The process of scrolling value.
 */
private void processScroll(@NotNull final ScrollEvent event) {
    if (!event.isControlDown()) return;

    final TextField source = (TextField) event.getSource();
    final String text = source.getText();

    float value;
    try {
        value = parseFloat(text);
    } catch (final NumberFormatException e) {
        return;
    }

    long longValue = (long) (value * 1000);
    longValue += event.getDeltaY() * 1;

    final String result = String.valueOf(max(min(longValue / 1000F, 1F), 0F));
    source.setText(result);
    source.positionCaret(result.length());

    processChange((KeyEvent) null);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:26,代码来源:AlphaInterpolationElement.java

示例4: getFileToCreate

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Gets file to create.
 *
 * @return the file to creating.
 */
@FromAnyThread
protected @Nullable Path getFileToCreate() {

    final TextField fileNameField = getFileNameField();
    final String filename = fileNameField.getText();
    if (StringUtils.isEmpty(filename)) return null;

    final String fileExtension = getFileExtension();

    final Path selectedFile = getSelectedFile();
    final Path directory = Files.isDirectory(selectedFile) ? selectedFile : selectedFile.getParent();

    return StringUtils.isEmpty(fileExtension) ? directory.resolve(filename) :
            directory.resolve(filename + "." + fileExtension);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AbstractFileCreator.java

示例5: editNameMode

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void editNameMode() {
	TextField t = new TextField();
	t.setMaxWidth(180);
	t.setText(moment.getNom());
	t.requestFocus();
	
	ChangeListener<Boolean>	 listener = new ChangeListener<Boolean>() {
		 @Override
		    public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
		    {
		        if (!newPropertyValue)
		        {
		        	RenameMomentCommand cmd = new RenameMomentCommand(nameController,moment.getNom(),t.getText());
					cmd.execute();
					UndoCollector.INSTANCE.add(cmd);
					borderPaneLabel.setCenter(label);
					t.focusedProperty().removeListener(this);
		        }
		    }
	};
	t.setOnKeyPressed(new EventHandler<KeyEvent>() {

		@Override
		public void handle(KeyEvent event) {
			if(event.getCode() == KeyCode.ENTER){
				t.setText(t.getText());
				borderPaneLabel.setCenter(label);
			}
			if(event.getCode() == KeyCode.ESCAPE){
				borderPaneLabel.setCenter(label);
			}
		}
	});
	t.focusedProperty().addListener(listener);
	Platform.runLater(()->t.requestFocus());
	Platform.runLater(()->t.selectAll());
	borderPaneLabel.setCenter(t);
}
 
开发者ID:coco35700,项目名称:uPMT,代码行数:39,代码来源:MomentExpVBox.java

示例6: handle

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

    TextField editor = comboBox.getEditor();
    String text = editor.getText();

    if (event.getCode() == KeyCode.RIGHT
            || event.getCode() == KeyCode.LEFT
            || event.isControlDown()
            || event.getCode() == KeyCode.HOME
            || event.getCode() == KeyCode.END
            || event.getCode() == KeyCode.TAB) {
        return;
    }
    else if(event.getCode() == KeyCode.UP) {
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.DOWN) {
        if(!comboBox.isShowing()) {
            comboBox.show();
        }
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.BACK_SPACE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }
    else if(event.getCode() == KeyCode.DELETE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }

    String upperCaseText = text.toUpperCase();
    ObservableList<T> list = FXCollections.observableArrayList(data.stream()
            .filter(s -> transform.apply(s).toUpperCase().startsWith(upperCaseText))
            .collect(Collectors.toList()));

    comboBox.setItems(list);

    if (event.getCode() == KeyCode.ENTER
            || event.getCode() == KeyCode.ESCAPE) {
        if (!list.isEmpty()) {
            comboBox.getEditor().setText(transform.apply(list.get(0)));
            comboBox.getSelectionModel().select(0);
            comboBox.hide();
        }
        else {
            comboBox.getEditor().setText(text);
        }

    }
    else {
        comboBox.getEditor().setText(text);
        if(!moveCaretToPos) {
            caretPos = -1;
        }
        moveCaret(text.length());
        if(!list.isEmpty()) {
            comboBox.show();
        }
    }

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:68,代码来源:AutoCompleteComboBoxListener.java

示例7: input2ArrayOfLongs

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static long[] input2ArrayOfLongs(TextField tf) throws NumberFormatException {

        String[] inputs = tf.getText().trim().split("[, ]+");
        long[] result = new long[inputs.length];
        try {
            for (int i = 0; i < inputs.length; i++) {
                result[i] = strPow(inputs[i]);
            }
        } catch (NumberFormatException ex) {
            throw new NumberFormatException("Invaild Number (" + tf.getText() + ")");
        }
        return result;
    }
 
开发者ID:WaleedMortaja,项目名称:Elementary-Number-Theory,代码行数:14,代码来源:HelpingClass.java

示例8: filtroFinancat

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public void filtroFinancat(TextField puna) {
    try {
        String sql;
        if (!puna.getText().isEmpty())
            sql = "select * from Punet where lower(lloji) like lower('%" + puna.getText() + "%') or lower(konsumatori) like lower('%" + puna.getText() + "%'" +
                    ") order by data desc";
        else
            sql = "select * from Punet order by data desc";
        Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        ObservableList<TabelaPunet> data = FXCollections.observableArrayList();
        Format format = new SimpleDateFormat("dd/MM/yyyy");
        while (rs.next()) {
            String d = format.format(rs.getDate("data"));
            data.add(new TabelaPunet(rs.getInt("id"), rs.getString("lloji").toUpperCase(), d,
                    rs.getFloat("qmimi"), rs.getString("konsumatori").toUpperCase(),
                    rs.getString("pershkrimi"), rs.getString("kryer"), rs.getString("makina").toUpperCase()));
        }
        tblPunet.getItems().clear();
        tblPunet.setItems(data);
        stmt.close();
        rs.close();
        conn.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:urankajtazaj,项目名称:Automekanik,代码行数:29,代码来源:DritarjaKryesore.java

示例9: updateValue

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * Update the value.
 */
@FXThread
private void updateValue(@NotNull final KeyEvent event) {
    if (isIgnoreListener() || event.getCode() != KeyCode.ENTER) return;

    final TextField valueField = getValueField();

    final String oldValue = getPropertyValue();
    final String newValue = valueField.getText();

    changed(newValue, oldValue);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:15,代码来源:StringPropertyControl.java

示例10: LabelOptionInit

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void LabelOptionInit (String configKey, String description, String def, FXController controller)
{
	this.description = new Label(description);
	this.description.setWrapText(true);
	
	textField = new TextField();
	oldValue = "";
	
	boolean noEntry = false;
	
	String dataValue = controller.getModel("config").getString(configKey);
	if (dataValue != null)
	{
		oldValue = dataValue;
	}
	else { noEntry = true; }
	
	if (noEntry)
	{
		Model m = controller.getModel("config");
		if (m != null) 
		{
			if (def == null)
			{
				m.doAction(Command.SET, configKey, "");
			}
			else
			{
				m.doAction(Command.SET, configKey, def);
				oldValue = def;
			}
		}
		else
		{
			debug.Debugger.out("Model config not found!");
		}
	}
	
	textField.setText(oldValue);
	listener = new InvalidationListener()
	{
		@Override
		public void invalidated (Observable observable)
		{
			String value = textField.getText();
			debug.Debugger.out(configKey + " property has changed to " + value);
			controller.getModel("config").doAction(Command.SET, configKey, value);
		}
	};
	textField.textProperty().addListener(listener);
}
 
开发者ID:CoffeeCodeSwitzerland,项目名称:Lernkartei_2017,代码行数:52,代码来源:LabelOption.java

示例11: showFileMovableDialog

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public Pair<FileAction, String[]> showFileMovableDialog(String bucket, String key, boolean setKey) {
	MainWindowController main = MainWindowController.getInstance();
	ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
	Dialog<String[]> dialog = getDialog(ok);

	TextField keyTextField = new TextField();
	keyTextField.setPrefWidth(300);
	keyTextField.setPromptText(Values.FILE_NAME);
	keyTextField.setText(key);
	ComboBox<String> bucketCombo = new ComboBox<String>();
	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<String[]> result = dialog.showAndWait();
	if (result.isPresent()) {
		bucket = bucketCombo.getValue();
		key = keyTextField.getText();
		FileAction action = copyasCheckBox.isSelected() ? FileAction.COPY : FileAction.MOVE;
		return new Pair<FileAction, String[]>(action, new String[] { bucket, key });
	} else {
		return null;
	}
}
 
开发者ID:zhazhapan,项目名称:qiniu,代码行数:44,代码来源:Dialogs.java

示例12: editNameMode

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void editNameMode() {
		TextField t = new TextField();
		t.setText(main.getCurrentMoment().getMoment().getNom());
		t.requestFocus();
		Platform.runLater(new Runnable() {
            @Override
            public void run() {
            	//Le Textfield demande le Focus
            	t.requestFocus();
            	//Si le text n'est pas vide, on selectionne tout.
            	if(!t.getText().isEmpty())
            		t.selectAll();
            }
        });
		
		ChangeListener<Boolean>	 listener = new ChangeListener<Boolean>() {
			 @Override
			    public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
			    {
			        if (!newPropertyValue)
			        {
			        	RenameMomentCommand cmd = new RenameMomentCommand(main.getCurrentMoment().getMomentNameController(),
								main.getCurrentMoment().getMoment().getNom(),t.getText());
						cmd.execute();
						UndoCollector.INSTANCE.add(cmd);
						vBoxLabel.getChildren().remove(t);
						vBoxLabel.getChildren().add(0,nomMoment);
						t.focusedProperty().removeListener(this);
			        }
			    }
		};
		t.setOnKeyPressed(new EventHandler<KeyEvent>() {

			@Override
			public void handle(KeyEvent event) {
				if(event.getCode() == KeyCode.ENTER){
					t.setText(t.getText());
					vBoxLabel.getChildren().remove(t);
				}
				if(event.getCode() == KeyCode.ESCAPE){
					vBoxLabel.getChildren().remove(t);
					vBoxLabel.getChildren().add(0, nomMoment);
				}
			}
		});
		t.focusedProperty().addListener(listener);
//		Platform.runLater(()->t.requestFocus());
//		Platform.runLater(()->t.selectAll());
		vBoxLabel.getChildren().add(0, t);
		vBoxLabel.getChildren().remove(nomMoment);
	}
 
开发者ID:coco35700,项目名称:uPMT,代码行数:52,代码来源:MainViewController.java


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