Reputation: 1425
In order to get the amount of players (required for a game), I implemented a spinner (from 2 to 8). In order to start the game, I need to get the selected item. I made some research and added the following code:
int numPlayers = (int) spinner.getValue();
But this solely returns the minimum spinner number, instead of returning the number selected by the user. Is there any other way to get the selected spinner number?
Upvotes: 0
Views: 239
Reputation: 285405
The key is when you call this code. For this to work, it must be part of a listener, possibly a ChangeListener, that has been added to your JSpinner.
Upvotes: 1