Issue
I have a problem with chosing correct action on TextField. On Java class:
@FXML
private TextField projectNameInput;
@FXML
private void clearProjectName(MouseEvent event) {
// some if - else statements
projectNameInput.clear();
}
On FXML it looks like this:
<TextField fx:id="projectNameInput" onMouseClicked="#clearProjectName" GridPane.columnIndex="1">
I tried most options, in Java I tried (as arg) Event, MouseEvent, ActionEvent, combined with FXML onAction
, etc but no luck. What kind of action should I choose that when I click the mouse button on TextField it will be automatically cleared?
Solution
TextField1.addEventFilter(KeyEvent.KEY_TYPED, numeric_Validation(5));
AutoControl.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
TextField1.clear();
}
}
Answered By - kintu david