Recognizing the text is handled by SpinnerListModel.findNextMatch(String substring), but this is private. (Presumably just an oversight.)
I tried taking my own copy of SpinnerListModel to make the method public (others have done the same, eg http://www.java9.net/code/4295.html), but this isn't recognized by JSpinner as a SpinnerListModel, so editing is disabled.
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.
I wouldn't join any Collection with an add() method that would accept me as a parameter
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.