Forums Register Login

Removal of swing event

+Pie Number of slices to send: Send
Hello,

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.

Do you know if it's possible ?

Cheers,

Chris
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hi,

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() .
+Pie Number of slices to send: Send
 

Aromal ayyappan wrote:Hi,

We can add a KeyListner to the Save Button,


Please don't. That's an even worse perjury than the occasional noob error of adding a MouseListener to a JButton.
+Pie Number of slices to send: Send
I would prefer method chaining.
Save-Validate-If validated, proceed, else warn the user.
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 761 times.
Similar Threads
Struts 1.3 Configuring different set of validations for the same ActionForm
URL parameters in Struts
event handling for med sized MVC app
Struts framework
How to get open or save dialog in struts.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:43:55.