I would like to intercept action on my save button. When the user click on save, I have a validor which is ran. In this validator I would like to cancel the "save" action in some cases. So I thought maybe it is possible to remove the save event from the event queue.
Why not just put an if condition in your button's event listener that only executes the save if all the conditions are met, and displays an error message otherwise?
Alternatively, you can just disable the save button when the conditions aren't right. In this case you will have to have event listeners in other components that determine the conditions, and disable or enable the save button depending on their state.
We can probably give you more advice if you provide us with a more detailed picture of when you don't want the user to be able to save something.
We can add a KeyListner to the Save Button, And inside the keyPressed () method , do the validation part.
If the validation is unsuccessful , we can use a keyevent.consume() .