spinner component

Daniel Zwolenski zonski at googlemail.com
Sun Dec 18 13:27:52 PST 2011


On Mon, Dec 19, 2011 at 6:57 AM, Tom Eugelink <tbee at tbee.org> wrote:
>
> Id vote for non-abbreviated method names though (even for well known
>> abbreviations like this) ie 'getIndex'
>>
>
> No problem, I was thinking about that as well. The "increment" and
> "decrement" on the spinner should become "next" and "previous" as well, to
> further hide the index from the spinner's API (this was evolutionary
> coding).
>
>  Would there ever be a need to select by index though (I'm hoping not)? I
>> can see a possible need for selectFirst (ie reset) but this is probably
>> achieved by knowing what the first 'value' should be and calling set with
>> that (eg setValue(new Date())).
>>
>
> You can always do index things through the data provider, like :
>
> I firstIndex = spinner.getDataProvider().**getPreviousIndex(null); //
> getting the previous of null returns the first index (this is also used
> when cycling).
> T firstValue = spinner.getDataProvider().**getValueForIndex( firstIndex );
> spinner.setValue(firstValue);
>
> It could be convenient to have some convenience methods (he he) like
> first, last.


>  Last minute thought. I haven't checked (typing on my phone) but is your
>> Spinner editable in the sense that you could free type in it (like the
>> ComboBox)? That might be nice - it should probably use the same
>> StringConverter design as ComboBox if it is to support this.
>>
>
> I have not thought about it. Editable spinner. Hm. How would that work?
> What happens if I type a value that is not part of the data provider?


Jonathan's just done some similar stuff in his ComboBox, might be worth a
look and see whether it could be adapted.

Otherwise, possibly the getIndex(Value) could return null or throw an
IndexOutOfBoundsException if it doesn't map back to an index - then the
Spinner could decide to do what it likes with that (maybe just leave the
'text' as is, set the value and index to null and optionally add a psuedo
style class of 'error').

On that same line of thought, your DatePicker is probably a specialisation
of the ComboBox as well. Worth a look anyway.


More information about the openjfx-dev mailing list