When I press a button, I want the spinner value to reset to 0 within an event handler.
Currently I have something like this:
Spinner sp = new Spinner();
int shAge;
....
EventHandler submitH = new EventHandler() {
@Override
public void handle(Event event) {
int shAge = Integer.parseInt(sp.getValue().toString());
....
System.out.println(shAge);
.....
and logically in my mind, to clear the spinner after the value has been added to an array list, there should be something like
sp.clear();
or
sp.reset();
however I can't seem to find anything like that when looking in the documentation.
If you only want to reset the value to 0
you can do:
sp.getValueFactory().setValue(0);
If you really want to clear the spinner you can additionally do:
sp.getEditor().clear();
But be aware that clearing the editor seems to be not fully supported. Using the increment and decrement buttons after that will throw a NullPointerException for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.