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


Java TextField.setOnKeyPressed方法代码示例

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


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

示例1: createTextField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
private void createTextField() {
    textField = new TextField(getString());
    textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0,
                Boolean arg1, Boolean arg2) {
            if (!arg2) {
                commitEdit(textField.getText());
            }
        }
    });

    textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent ke) {
            KeyCode kc = ke.getCode();
            if ((kc.equals(KeyCode.ENTER) || kc.equals(KeyCode.UP) || kc.equals(KeyCode.DOWN) || kc.equals(KeyCode.LEFT) || kc.equals(KeyCode.RIGHT))) {
                commitEdit(textField.getText());
            }
        }
    });
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:24,代码来源:IsotopesManagerController.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: ParamField

import javafx.scene.control.TextField; //导入方法依赖的package包/类
ParamField(String name, Property<T> prop, Class<T> genericType) {
	field = new TextField();
	Label lbl = new Label(name);
	valueProperty = prop;
	this.genericType = genericType;
	
	lastValue = prop.getValue();
	field.setText(lastValue.toString());
	field.setOnKeyPressed(e ->{
		if(e.getCode() == KeyCode.ENTER)
			newValue();
	});
	field.focusedProperty().addListener((obs, o, n)->{
		if(o.booleanValue() && !n.booleanValue())
			newValue();
	});
	
	root = new VBox();
	root.getChildren().addAll(lbl, field);
}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:21,代码来源:VisionEditorWindow.java

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

示例5: createTableFilter

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static SortedList<Ticket> createTableFilter(TextField textSearch, ListView listView){

        if(isPrepared)
            return new SortedList<>(filteredTickets);

        textSearch.setOnKeyPressed((KeyEvent ke) ->{
            if(ke.getCode().equals(KeyCode.ENTER)){
                text = textSearch.getText().toLowerCase();
                filterTickets();
            }
        });

        //Listview
        listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                categoryText = newValue.split(" ")[0];
                if(categoryText.equals("DownloadPlayChild"))
                    categoryText = "DLP";
                filterTickets();
            }
        });

        isPrepared = true;
        return new SortedList<>(filteredTickets);
    }
 
开发者ID:Ptrk25,项目名称:CDN-FX-2.2,代码行数:27,代码来源:TDATableFilter.java

示例6: createTableFilter

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static SortedList<Ticket> createTableFilter(TextField textSearch, ListView listView){

        if(isPrepared)
            return new SortedList<>(filteredTickets);

        textSearch.setOnKeyPressed((KeyEvent ke) ->{
            if(ke.getCode().equals(KeyCode.ENTER)){
                text = textSearch.getText();
                filterTickets();
            }
        });

        //Listview
        listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                categoryText = newValue.split(" ")[0];
                if(categoryText.equals("DownloadPlayChild"))
                    categoryText = "DLP";
                filterTickets();
            }
        });

        isPrepared = true;
        return new SortedList<>(filteredTickets);
    }
 
开发者ID:Ptrk25,项目名称:CDN-FX-2.2,代码行数:27,代码来源:TMTableFilter.java

示例7: consumeKeys

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public static void consumeKeys(TextField tf) {
    tf.setOnKeyPressed(key -> {
        if (ctrlY.match(key) || ctrlZ.match(key)) {
            key.consume();
        }
    });
}
 
开发者ID:nonilole,项目名称:Conan,代码行数:8,代码来源:ViewUtil.java

示例8: TextAreaReadline

import javafx.scene.control.TextField; //导入方法依赖的package包/类
public TextAreaReadline(TextField text, TextArea output, final String message) {
    this.area = text;
    this.output = output;
    readline = new Readline();
    inputJoin.send(Channel.EMPTY, null);
    text.setOnKeyPressed(this);
    if (message != null) {
        append(message, promptStyle);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:TextAreaReadline.java

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

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