I want to make a JSpinner and when you change it, it will prompt you, "Are you sure you want to change this?" All I can find is the ChangeListener and that only gets run when you change it. I want the spinner to not change until they click "yes" in the dialogue.
Asked
Active
Viewed 30 times
0
-
2Take a look at the `PropertyChangeListener`, it will give you both the old and new values, you "could" reset the value – MadProgrammer Jan 23 '15 at 00:17
-
1You could implement your own `SpinnerModel`, which, when updated, calls a post-validation callback which is responsible for returning `true` or `false` indicating if the value should be changed. Just so you know, if I was the user of your application, I would not like you, not like you at all for doing this to me...just saying... – MadProgrammer Jan 23 '15 at 00:19
-
The reason I am doing this is because a calculation is made based on this spinner value. If they change it after the calculation, they will have to re-do it. Does the `PropertyChangeListener` replace the `ChangeListener`? – Christopher Smith Jan 23 '15 at 00:21
-
1`PropertyChangeListener` simply provides you more information (old value and new value), it will still occur only after the value has actually been applied. You could focus on invalidating the results when a change occurs instead of popping up message each time they try and change, but that's your requirements not mine, I just like to try and stay out the way of the user as much as possible, but that's me – MadProgrammer Jan 23 '15 at 00:26