Java Code Examples for javafx.scene.control.TextField#addEventFilter()

The following examples show how to use javafx.scene.control.TextField#addEventFilter() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: phoebus   File: RTImagePlot.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private TextField constructAxisLimitsField()
{
	final TextField field = new TextField();
	//prevent mouse-clicks in TextField from triggering MouseClicked event for RTPlot
	field.addEventFilter(MouseEvent.MOUSE_CLICKED, (event)->event.consume());
	field.focusedProperty().addListener((prop, oldval, newval)->
	{
		if (!newval) hideAxisLimitsField();
	});
	field.setVisible(false);
	field.setManaged(false); //false because we manage layout, not the Parent
	return field;
}
 
Example 2
Source Project: phoebus   File: RTPlot.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private TextField constructAxisLimitsField()
{
	final TextField field = new TextField();
	//prevent mouse-clicks in TextField from triggering MouseClicked event for RTPlot
	field.addEventFilter(MouseEvent.MOUSE_CLICKED, (event)->event.consume());
	field.focusedProperty().addListener((prop, oldval, newval)->
	{
		if (!newval) hideAxisLimitsField();
	});
	field.setVisible(false);
	field.setManaged(false); //false because we manage layout, not the Parent
	return field;
}
 
Example 3
Source Project: trex-stateless-gui   File: PacketHex.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
public TextFieldCell() {
    textField = new TextField();
    textField.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(50));
    textField.getStyleClass().add("hexTextFieldEditor");
    textField.setEditable(false);
    textField.setOnMouseClicked((MouseEvent mouseEvent) -> {
        if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
            handleMouseClickedEvent();
        }
    });
    this.setGraphic(textField);
}
 
Example 4
Source Project: trex-stateless-gui   File: PacketHex.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show dialog
 *
 * @param selectedText
 * @return
 */
private String showDialog(String selectedText) {
    Dialog dialog = new Dialog();
    dialog.setTitle("Edit Hex");
    dialog.setResizable(false);
    TextField text1 = new TextField();
    text1.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(2));
    text1.setText(selectedText);
    StackPane dialogPane = new StackPane();
    dialogPane.setPrefSize(150, 50);
    dialogPane.getChildren().add(text1);
    dialog.getDialogPane().setContent(dialogPane);
    ButtonType buttonTypeOk = new ButtonType("Save", ButtonData.OK_DONE);
    dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
    dialog.setResultConverter(new Callback<ButtonType, String>() {
        @Override
        public String call(ButtonType b) {
            
            if (b == buttonTypeOk) {
                switch (text1.getText().length()) {
                    case 0:
                        return null;
                    case 1:
                        return "0".concat(text1.getText());
                    default:
                        return text1.getText();
                }
            }
            return null;
        }
    });
    
    Optional<String> result = dialog.showAndWait();
    if (result.isPresent()) {
        return result.get();
    }
    return null;
}