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


Java TextField.requestFocus方法代码示例

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


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

示例1: onButtonAction

import javafx.scene.control.TextField; //导入方法依赖的package包/类
@FXML
public void onButtonAction(ActionEvent event) {
	System.out.println("Button Clicked");
	Scene scene = stage.getScene();
	
	TextField inputTextField = (TextField) scene.lookup("#textfield");
       
       JsonObject str = new JsonObject();
       str.addProperty("text", inputTextField.getText().replaceAll("\"", "\\\"").trim());
       
       if (str != null && inputTextField.getText().length() > 0) {
       	str.addProperty("intent", "message");
           chatAccess.send(gson.toJson(str));
       }
       
       inputTextField.selectAll();
       inputTextField.requestFocus();
       inputTextField.setText("");
       
       runnable.run();
       
}
 
开发者ID:Miic,项目名称:WholesomeChat,代码行数:23,代码来源:MainController.java

示例2: 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

示例3: startEdit

import javafx.scene.control.TextField; //导入方法依赖的package包/类
static <T> void startEdit(final Cell<T> cell,
        final StringConverter<T> converter,
        final HBox hbox,
        final Node graphic,
        final TextField textField
) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
开发者ID:Naoghuman,项目名称:ABC-List,代码行数:25,代码来源:CellUtils.java

示例4: ASMCreationPanel

import javafx.scene.control.TextField; //导入方法依赖的package包/类
/**
 * @param onCreateASM
 *            Method to call when "create" is clicked. This parameter must be
 *            non-null.
 * 
 * @throws IllegalArgumentException
 *             if onCreateASM is null
 */
public ASMCreationPanel(Consumer<ASMCreationDetails> onCreateASM)
{
	if (onCreateASM == null)
		throw new IllegalArgumentException("onCreateASM must be non-null");
	
	this.onCreateASM = onCreateASM;
	this.setPadding(new Insets(20));
	GridPane grid = new GridPane();
	HBox buttons = new HBox(10);
	grid.setHgap(10);
	grid.setVgap(30);
	grid.setPadding(new Insets(10, 10, 10, 10));
	
	Label ASMFileName = new Label();
	ASMFileName.setText("File Name: ");
	ASMFileName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	nameText = new TextField();
	nameText.setText("");
	nameText.requestFocus();
	nameText.setPrefWidth(200);
	
	Label projectName = new Label();
	projectName.setText("Add to Project: ");
	projectName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
	
	projectListDropdown = new ComboBox<>();
	
	Button create = new Button();
	create.setText("Create");
	create.setOnAction(this::onCreateASMClicked);
	
	grid.add(ASMFileName, 0, 0);
	grid.add(nameText, 1, 0);
	grid.add(projectName, 0, 1);
	grid.add(projectListDropdown, 1, 1);
	
	this.setCenter(grid);
	buttons.getChildren().add(create);
	buttons.setAlignment(Pos.BASELINE_RIGHT);
	this.setBottom(buttons);
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:51,代码来源:ASMCreationPanel.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: 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.requestFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。