This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
1) Never ever use == to compare Strings, use .equals
2) The actual value returned by SpinnerNumberModel is not a String but a Number, usually a Double or Integer. In your case it's probably Integer. Compare that:
Note that I used Number instead of Integer. This will allow your code to continue working if you start using Long, Double, Float, Short, etc. All of these allow you to retrieve the value as an int using intValue().
Read the JSpinner API and follow the link to the section in the Swing tutorial on "How to Use Spinners" where you will find a demo that uses a ChangeListener on a spinner with a DateSpinnerModel. I'm sure your code would be similiar except you are using a number model.
Joined: May 26, 2011
Thank you for your replys
I'll keep those tips in mind from now on
I managed to fix it and get it working, cheers a lot guys!
(I am trying to learn this, not just use you guys to make the code for me, I do spend an hour or so trying to fiqure out what you've told me to do and what it's doing)