In this part of the Java Video Tutorial, I focus on the Java Swing JSpinner component. I’ll show you how to cycle through numbers, dates and just about anything else. I also revisit the Dimension, Date and Calendar libraries.
Most Java Tutorials gloss over topics like this, but I decided I wanted to create a truly comprehensive tutorial.
Just like always it is best to follow the tutorial with the code. It follows the video.
If you like videos like this, share it [nttfblike]
Code From the Video
Hi, Derek, great tuts you got here, it really helps me learn Java =) However, typing this code from video I noticed that spinner1 won’t stop at 9, but will keep counting up (here’s a link to a screenshot I made http://imgur.com/wSyBW). I guess the default width doesn’t support displaying more than 1 digit…
What do you think?
Thank you 🙂 This is where you define your jspinner in the code
// Create a spinner with initial number, starting number,
// max number, increment with each click
spinner2 = new JSpinner(new SpinnerNumberModel(1, 1, 100, 1));
I hope that helps