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?
If you want to erase the content of the label, do: final Label result = ... root. add(result, 0, 1); button.
In FXML, add editable="false" to your TextField tag. Or uncheck the "Editable" checkbox in Scene Builder.
TextField1.addEventFilter(KeyEvent.KEY_TYPED, numeric_Validation(5));
AutoControl.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
TextField1.clear();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With