This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
To get around this, I took my own copy of JSpinner, but this failed with
UIDefaults.getUI() failed: no ComponentUI class for: sun.com.JSpinner[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=]
java.lang.Error at javax.swing.UIDefaults.getUIError(Unknown Source)
Would the solution be to monitor the contents of the TextField and pre-convert the typing into the values in the list?
Grateful for any suggestions.
You wait all this time for a coincidence, then two come along at once...
The case? I suppose you have the months displayed like Jan and Oct? I have a year-and-month version of JSpinner which works just fine (although it's a bit un-intuitive), I use numeric months.
Edit: I tracked down the code, here's the important bits from the constructor:
Joined: Nov 09, 2008
Thanks Paul and Michael.
It was actually just SpinnerListModel, but formatting is what I needed (although it doesn't handle the general case where the list is coming from a source you don't have control over)
what are you trying to achieve?
Learning exercise. Am evaluating Spinners. That was just a simple example that showed a problem I was hitting elsewhere.
There is a second problem when the Object is something more complex than String.
As you type, it recognizes the entry, but on loss of focus the Spinner flips back to the previously selected value. System.out.println shows my Object's toString() method is returning the value that matches what I typed, so it should work?
On the topic of calendars and date-pickers, I'd be interested in your recommendations.